length属性获取jQuery元素集合中元素的个数。
语法结构:
$(selector).length
代码实例:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function () {
$("div").text($("li").length);
})
})
</script>
</head>
<body>
<div></div>
<ul>
<li>后台专区</li>
<li>前台专区</li>
<li>数据库专区</li>
<li>站长专区</li>
</ul>
<input type="button" value="查看效果" id="btn"/>
</body>
</html>
http://www.softwhy.com/article-997-1.html
http://www.softwhy.com/qiduan/jQuery_source/
http://www.softwhy.com/