jQuery怎么动态生成列表
1个回答
展开全部
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<ul class="ul">
</ul>
<button class="btn">加载</button>
<script src="jquery-1.11.3.js"></script>
<script>
var arr=[1,2,3,4,5,6,7,8];
$('.btn').click(function () {
for(var i=0;i<arr.length;i++){
$('.ul').append('<li>'+arr[i]+'</li>')
}
})
</script>
</body>
</html>
关键点在append方法;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询