How to Count Number of Rows in Table Jquery?

By Hardik Savani | March 29, 2020 | Category : jQuery


Hi Dev,

In this tutorial, i will show you how to get number of rows in table jquery. This post will give you simple example of how to find number of rows in table jquery. i would like to show you how to count number of rows in table using jquery.

if you want to see example of how to find no of rows in a table in jquery then you are a right place. Follow bellow tutorial step of how to get number of rows in html table using jquery.

So, let's see bellow simple solution with example that will help you to getting count numbe r of rows in table using jquery.

Solution:

var trCount = $('#myTable tr').length;

Example:

<!DOCTYPE html>

<html>

<head>

<title>jquery count number of table row - itsolutionstuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

</head>

<body>

<h1>jquery count number of table row - itsolutionstuff.com</h1>

<table id="myTable">

<tr>

<th>ID</th>

<th>Name</th>

</tr>

<tr>

<td>1</td>

<td>Hardik</td>

</tr>

<tr>

<td>2</td>

<td>Vimal</td>

</tr>

<tr>

<td>3</td>

<td>Harshad</td>

</tr>

</table>

<button >Click Me!</button>

<script>

$(document).ready(function(){

$('button').click(function(){

var trCount = $('#myTable tr').length;

alert(trCount);

});

});

</script>

</body>

</html>

I hope it can help you...



Tags : jQuery


Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: