Get Count (Number) of Rows in HTML Table using jQuery

The following HTML Markup consists of an HTML Table and a Button to get count (number) of rows in HTML Table using jQuery.


<table id="tblCustomers" border="0" cellpadding="0" cellspacing="0">
            <th style="width: 90px">Customer Id</th>
            <th style="width: 120px">Name</th>
            <th style="width: 90px">Country</th>
            <td>John Hammond</td>
            <td>United States</td>
            <td>Mudassar Khan</td>
            <td>Suzanne Mathews</td>
            <td>Robert Schidner</td>
<br />
<input type="button" id="btnGetCount" value="Count Rows" />


<script type="text/javascript" src=""></script>
<script type="text/javascript">
   $(function () {
        $("#btnGetCount").click(function () {
            var totalRowCount = $("#tblCustomers tr").length;
            var rowCount = $("#tblCustomers td").closest("tr").length;
            var message = "Total Row Count: " + totalRowCount;
            message += "\nRow Count: " + rowCount;

Related Post

Latest Post

Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.