How to Count Number of Rows in a Table Using jQuery


Use the length Property

You can simply use the length property to count or find the number of rows in an HTML table using jQuery. This property can be used to get the number of elements in any jQuery object.

Let's try out the following example to understand how it actually works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Get Number of Rows in a Table</title>
<script src=""></script>
            var rowCount = $("#myTable tr").length;
            alert(rowCount); // Outputs: 4
    <table id="myTable">
    <button type="button">Get Number of Rows</button>