size() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:size

Description

The size() method was deprecated in version 1.8 and removed in jQuery version 3.0. Use the length property instead.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        console.log($("li").size());

    });//w  ww  .j  a v a 2 s  .c om
});
</script>
</head>
<body>

<button>test</button>

<ul>
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>

</body>
</html>

Related Tutorials