How to Count Number of Rows in Table 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. 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, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- JQuery Radio Button Change Event Example
- How to Set Radio Button Checked Based on Value using JQuery?
- How to Get Checked Radio Button Value by Name in JQuery?
- How to Check If Checkbox is Checked or Not in JQuery?
- PHP Signature Pad Example | E-Signature Pad using Jquery Ajax and PHP
- JQuery Open Link in New Tab on Click Example
- JQuery Open Link in New Window Example
- How to Add Lazy Loading Image using JQuery?
- Check and Uncheck All Checkbox using JQuery Example
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How to Check Undefined, Empty and Null in JQuery?
- How to Convert Line Breaks to br in jQuery ?
- How to Check Object is Empty or Not in JQuery?