具有隐藏行的表格的jQuery选择器-备用行着色 [英] JQuery Selector for table with hidden row - alternate row colouring
问题描述
我有一张桌子,通常我使用此选择器来应用奇数行和偶数行:
I have a table, and usually i use this selector to apply odd and even row:
table.find('tbody tr:even').addClass('even');
table.find('tbody tr:odd').removeClass('even');
我的表在不同位置插入了行,因此为什么我从奇数行中删除它.
My Table has rows being inserted at various places, hence why i remove it from the odd rows.
我现在使用
jQueryTrObject.hide();
我想应用与以前相同的样式,以便就用户而言,将交替的行标记为奇数和偶数,并且我希望它考虑隐藏的行.
I want to apply the same styling as before, so that alternate rows, as far as the user is concerned are marked up odd and even, and i'd like it to take into account of hidden rows.
我该如何编写选择器,因为我必须使用each并专门检查?
How do i write a selector to do this, for do i have to use the each and specifically check?
推荐答案
使用 :visible
选择器
use the :visible
selector
table.find('tbody tr.even').removeClass('even');
table.find('tbody tr:visible:even').addClass('even');
请记住首先使用它,以便在其后应用:even
过滤器.
Remember to use it first so that the :even
filter applies after it.
这篇关于具有隐藏行的表格的jQuery选择器-备用行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!