Counting hidden table rows using JQuery
I 开发者_如何学Gohave a a table with a couple of hidden rows. What I want to achieve is having it show a hidden row with each button click, is this possible?
I count the number of table rows using the following
var rowCount = parseInt($('#Table tr').length);
How do I count hidden table rows?
Try
$('#Table tr:hidden').length
:hidden selector
As stated by others, you can specify hidden elements in your selector with the :hidden
selector.
$("#Table tr:hidden").length; //number of hidden <TR> elements
As for showing each one with each sequential click of a button, you could make use of the :first
selector as well:
$(".showRow").click(function(){
$("#Table tr:hidden:first").show();
});
Demo: http://jsfiddle.net/J3QdQ/
It is possible through : hidden operator
$('#Table tr:hidden').length
精彩评论