Reputation: 1249
I have the following in a page the var rows shows length=1 but then it reaches the .each statement it doesn't enter it. I must be missing something. I only have this problem when there is only 1 row in the table. Any thoughts?
$('.addnewrow').click(function() {
var rows = $('#webgrid tr:gt(0)');
rows.each(function (index) {
// do something
});
// now do something else based on the results of the .each
});
Upvotes: 0
Views: 237
Reputation: 1641
In #webgrid tr:gt(0)
, you are selecting every tr
which has the ancestor #webgrid
AND is in a index position GREATER THAN 0 (gt(0)
), in this case, using the :gt()
pseudo selector is useless if you want to iterate through all the tr
. Since gt(0)
means "every element that is at a index above 0" and you only have one element at position 0, you are missing it alltogether.
Hope this helps!
Upvotes: 1