size

UK[saɪz] 美[saɪz]

n. Scale; size, size; glue, paste; huge, large amount

vt. Arrange according to size; change the size of; apply glue, sizing; apply paint

adj. Certain size

jquery size() method syntax

Function: size() method returns the number of elements matched by the jQuery selector.

Syntax: $(selector).size()

jquery size() method example

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    alert($("li").size());
  });
});
</script>
</head>
<body>
<button>输出 li 元素的数目</button>
<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Soda</li>
</ul>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance