I have a table and i want to count how many tr i hide.
The code:
<rich:jQuery query="ready(function() {
var i = 0;
jQuery('#inbox:_inboxTable_').find('span[title=isArchivedStatusPlusIncludeArchive]').each(function(i, o){
if (jQuery(this).text() == 'true+false' ){
i++;
alert(i);
jQuery(this).parent().parent().parent().fadeOut();
}
jQuery('#inbox').find('span[title=documentProccesedCountTitle]').html(i+' documents are beeing processed to be remove开发者_如何学Pythond from the inbox');
});
})"/>
For a page with 10 tr, in my test 7 are hidden by this part of code but 'i' is 10 instead of 7 at the last step...
I just have no clue...why? Does anyone see the reason?
Thanks in advance.
What about:
$("#table_id tr:hidden").length
i=10
because you are using it as an index of the function, try using j
or something else:
jQuery('#inbox:_inboxTable_').find('span[title=isArchivedStatusPlusIncludeArchive]').each(function(j, o){
...
}
Also, instead of using jQuery(this).parent().parent().parent().fadeOut();
you could use the closest jQuery(this).closest('tr').fadeOut();
(if the tr
is your target).
精彩评论