首页javascriptuljQuery HTML Element - 如何添加LI项

jQuery HTML Element - 如何添加LI项

我们想知道如何添加LI项。


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
#newLine .dog {
  color: #F00;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('button').click(function(){
        $('#newLine').append("<li class='dog'>Dog</li>");
    });
});
</script>
</head>
<body>
  <UL id='newLine'></UL>
  <button>click</button>
</body>
</html>