jQuery tablesorter插件-保留其他行颜色 [英] jquery tablesorter plugin - retain alternative row colors

查看:180
本文介绍了jQuery tablesorter插件-保留其他行颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拿了一个html表,在其中应用其他行颜色,并在上面添加了jquery表排序器,以便用户可以对表进行排序.

I took an html table that I am applying alternative row colors to, and I added jquery table sorter on it so users can sort the table.

问题在于,由于存在多行具有相同背景色的行(基于排序),所有可选行的颜色现在都被弄乱了.

The issue is that the alternative row colors are all messed up now as (based on the sorting) there are multiple rows with the same background color.

有什么方法可以用jquery表排序器重置替代行的颜色吗?

Is there any way to reset the alternative row color with jquery table sorter?

推荐答案

核心中已经内置了默认控件zebra,该控件将类oddeven应用于替代行.无论是否已将class=even/odd添加到html文件中,它都可以工作.

There's already a default widget zebra, built into the core, which applies the classes odd and even to alternate rows. It works whether or not you have added class=even/odd to the html file.

设置起来真的很容易.我只是按照表分类器网站上的说明进行操作,然后将文档准备功能修改为以下内容: /p>

It's really easy to set up. I simply followed the instructions on the table sorter website, and then modified the document ready function to the following:

<script type="text/javascript">
$(document).ready(function() 
    { 
        $("#myTable").tablesorter({ 
    widgets: ['zebra'] 
    }); 
    } 
); 
</script>

我在回答问题时举了一个例子.您可以查看实际结果,或

I made an example while answering the question. You can view the result in action, or see the example code.

这篇关于jQuery tablesorter插件-保留其他行颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆