$(selector).length
<!DOCTYPE html>
<html>
<head>
<script src = "/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("#b1").click(function(){
alert($("p").length);
});
});
</script>
</head>
<body>
<h4> This is an example of using the jQuery length property </h4>
<p> First paragraph </p>
<p> Second paragraph </p>
<p> Third paragraph </p>
<h5> Click the following button to count the number of paragraph elements. </h5>
<button id = "b1"> Click me </button>
</html>