动态更改备用行颜色

时间:2011-04-30 09:58:20

标签: javascript jquery

我有5 tr,这些是行替代颜色。现在,当我删除某行时,如何动态更改tr颜色。

以下假设是表tr和td

这是我的行

tr class='odd'  
tr class='even'
tr class='odd'
tr class='even'
tr class='odd'
tr class='even'
tr class='odd'


tr class='odd'
tr class='even' if I delete this tr, than 
tr class='odd'
tr class='even'
tr class='odd'
tr class='even'
tr class='odd'


tr class='odd'
tr class='even'  class changed  odd to even
tr class='odd'   class changed  even to odd
tr class='even'  class changed  odd to even
tr class='odd'   class changed  even to odd
tr class='even'  
tr class='odd'

2 个答案:

答案 0 :(得分:1)

你可以这样做:

$('table tr:even td').css("background-color":"");
$('table tr:odd td').css("background-color":"");

答案 1 :(得分:1)