.length
描述: 在jQuery对象中元素的数量。
目前匹配的元素数量。.size()方法将返回相同的数字。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="jquery-1.10.2.js"></script>
<style>
body{ cursor:pointer;}
div { width:50px; height:30px; margin:5px; float:left; background:#0F0; }
span { color:red; }
</style>
</head>
<body>
<span></span>
<div></div>
<script>
$(document.body).click(function(){
$(document.body).append($("<div>"));
var n = $("div").length;
$("span").text("There are " + n + " divs." + "Click to add more.");
}).trigger('click');
</script>
</body>
</html>
效果图: