Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Count (Get) Number of Rows in Table with Example

May 19, 2015
Introduction

Here I will explain how to get number of rows count in table in
jQuery or count number of rows in table in jQuery with example or jQuery get number of table rows length or jQuery get rows length in table with example.


To get number of rows in table using jQuery we need to write the code like as shown below


<script type="text/javascript">
$(function () {
$('#btnGetRows').click(function () {
var rowCount = $('#tblDetails tr').length;
alert(rowCount);
})
});
</script>


If you want to check it in complete example you need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Get Number of Rows Count in Table</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function () {
$('#btnGetRows').click(function () {
var rowCount = $('#tblDetails tr').length;
alert(rowCount);
})
});
</script>
</head>
<body>
<form id="form1">
<div>
<table id="tblDetails">
<tr>
<th>UserId</th>
<th>UserName</th>
<th>Education</th>
<th>Location</th>
</tr>
<tr>
<td>1</td>
<td>Suresh Dasari</td>
<td>B.Tech</td>
<td>Chennai</td>
</tr>
<tr>
<td>2</td>
<td>Rohini Alavala</td>
<td>Msc</td>
<td>Chennai</td>
</tr>
<tr>
<td>3</td>
<td>Mahendra D</td>
<td>CA</td>
<td>Chennai</td>
</tr>
</table>
<input type="button" id="btnGetRows" value="Get Rows" />
</div>
</form>
</body>
</html>

Live Demo

For live demo try to click on below button to get rows count. Generally it will return all rows including header row


UserId UserName Education Location
1 Suresh Dasari B.Tech Chennai
2 Rohini Alavala Msc Chennai
3 Mahendra D CA Chennai



If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

0 comments :

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.