Basically, Is it possible to get a grids row count using jquery.
if my grid has 20 rows in it not including the header or footer, i want to now the count of actual rows, this will 开发者_如何学JAVAtell my users how many tasks they have in their list.
Since, my page uses tabs i want the user to be able to see the count of each grid in its respective tab. each tab has a label and i want that label to have the number of rows.
Using jquery:
$("tr").length();
This will return the number of table rows on a given page. Of course, you could be more specific by passing a DOM id or a class to count. If you provide the markup in question, I could help you get it right.
If each of your rows has a class then you can use jquery's length attribute to count how many rows there are
Here's an example (i've used divs)
<div class="test">Test 1</div>
<div class="test">Test 2</div>
<div class="label">fdgdfg</div>
And the jquery
$('.label').text($('.test').length)
EDIT
To do this for rows within a div
$('.label').text($('div.test tr').length)
<div class="test">
<table>
<tr><td>something</td></tr>
<tr><td>something else</td></tr>
</table>
</div>
By rows I assume you mean tr
Here's an updated jsFiddle
var rowsCount = $("#<%=GridView.ClientID %> tr").length;
精彩评论