admin管理员组文章数量:1327931
i am using a table with alternate row color and the same table has sorting functionality with jquery.tablesorter.js. as follow.
css can be applied for alternative row like.
$("tr:even",$(this)).css({'backgroundColor':'#ffffff'});
$("tr:odd",$(this)).css({'backgroundColor':'#ebf0f5'});
sorting can be done by
function sortTable(tableID)
{
$("#"+tableID).tablesorter();
}
First time alternative row color works fine.
But When I sort the records the format has been changed. and alternative row color is not working.
Any help will be appreciated.
i am using a table with alternate row color and the same table has sorting functionality with jquery.tablesorter.js. as follow.
css can be applied for alternative row like.
$("tr:even",$(this)).css({'backgroundColor':'#ffffff'});
$("tr:odd",$(this)).css({'backgroundColor':'#ebf0f5'});
sorting can be done by
function sortTable(tableID)
{
$("#"+tableID).tablesorter();
}
First time alternative row color works fine.
But When I sort the records the format has been changed. and alternative row color is not working.
Any help will be appreciated.
Share Improve this question edited Jun 29, 2011 at 7:49 Hardik Patel asked Jun 29, 2011 at 7:00 Hardik PatelHardik Patel 9373 gold badges14 silver badges39 bronze badges 3- How do you color the rows? if you're using CSS's :nth-child(odd/even), it should be ok. – yoavmatchulsky Commented Jun 29, 2011 at 7:02
- The last time I did some table sorting was a while ago, but from what I remember whichever JQuery sort routine I used did the alternate colours automatically. Perhaps if you post some of your HTML/CSS/JS? – nnnnnn Commented Jun 29, 2011 at 7:11
- hi i am using . $("tr:even",$(this)).css({'backgroundColor':'#ffffff'}); $("tr:odd",$(this)).css({'backgroundColor':'#ebf0f5'}); – Hardik Patel Commented Jun 29, 2011 at 7:33
3 Answers
Reset to default 5Use the zebra widget:
$("table").tablesorter({widgets: ['zebra']})
after sort pleted you can run this jquery code:
$("table <make it more specific!>").find("tr").removeClass("alt").filter(":odd").addClass("alt");
Here is the jsFiddler code.
Use this:
$('#table').tablesorter({
widgets : ['zebra'],
widgetZebra : {
css: ['your_even_css_class_name', 'your_odd_css_class_name']
}
});
And remove this:
$("tr:even",$(this)).css({'backgroundColor':'#ffffff'});
$("tr:odd",$(this)).css({'backgroundColor':'#ebf0f5'});
本文标签:
版权声明:本文标题:javascript - After sorting table, The alternate row color in table row is not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742254794a2441431.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论