ItSolutionStuff.com

How to Count Number of Rows in Table JQuery?

By Hardik Savani • July 21, 2023
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

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

JQuery Radio Button Change Event Example

Read Now →

How to Set Radio Button Checked Based on Value using JQuery?

Read Now →

How to Get Checked Radio Button Value by Name in JQuery?

Read Now →

How to Check If Checkbox is Checked or Not in JQuery?

Read Now →

PHP Signature Pad Example | E-Signature Pad using Jquery Ajax and PHP

Read Now →

JQuery Open Link in New Tab on Click Example

Read Now →

JQuery Open Link in New Window Example

Read Now →

How to Add Lazy Loading Image using JQuery?

Read Now →

Check and Uncheck All Checkbox using JQuery Example

Read Now →

How to Allow Only One Checkbox Checked at a Time in JQuery?

Read Now →

How to Check Undefined, Empty and Null in JQuery?

Read Now →

How to Convert Line Breaks to br in jQuery ?

Read Now →

How to Check Object is Empty or Not in JQuery?

Read Now →