javascript - jQuery tablesorter - 向表行添加样式的 IE8 问题

标签 javascript jquery css internet-explorer-8 tablesorter

使用 jQuery tablesorter 对表中的每个奇数行进行排序并赋予样式。

问题:IE8 忽略表格行背景或不会为奇数行应用样式。知道如何使它适用于 IE < 9 吗?

这是 http://jsfiddle.net/rdos/kg7e771g/3/ - 这在除 IE < 10

以外的所有浏览器中都可以正常工作

谢谢!

JSP:

<html>
<head>
<style type="text/css">
.tablesorter tbody tr:nth-child(odd) {
    background-color: #faf4e2;
}
</style>

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.21.5/js/jquery.tablesorter.js"></script>
<script type="text/javascript">
    $(document).ready(function() {          
            $("#myTable").tablesorter();            
        } 
    ); 
</script>
</head>

<body>
<table id="myTable" class="tablesorter"> 
<thead> 
<tr> 
    <th>Last Name</th> 
    <th>First Name</th> 
    <th>Email</th>     
</tr> 
</thead> 
<tbody> 
<tr> 
    <td>Saul</td> 
    <td>Tarsus</td> 
    <td>st@mail.com</td> 
   </tr> 
<tr> 
    <td>Paul</td> 
    <td>Rock</td> 
    <td>pr@mail.com</td>     
</tr> 
</tbody> 
</table> 
</body>
</html>

最佳答案

可以加td统治

.tablesorter tbody tr:nth-child(odd) td{
    background-color: #faf4e2;
}

或者

  .tablesorter tbody tr:nth-child(odd), .tablesorter tbody tr:nth-child(odd) td{
        background-color: #faf4e2;
    }

或者

在添加 td 的样式标签周围添加 IE 条件注释规则所以它只在IE < 9生效

关于javascript - jQuery tablesorter - 向表行添加样式的 IE8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30064791/

相关文章:

javascript - 添加新 HTML 项目后丢失事件触发

jquery - 无法为输入类型文件添加 jquery 类

javascript - 使用 Chart.Js 绘制最高(绿色)和最低(红色)坐标图

javascript - 如何使用选项值禁用文本框

javascript - 更改 lodash groupby key 为 undefined

javascript - 表单和 JavaScript

javascript - 使用 getSelected() 获取所选文本的范围 ID

html - 我网站的顶部横幅和背景图像仅显示在 IE 中,而不显示在 FF 中。怎么了?

CSS3 动画 : Can't get my span to slide up

css - IE6 中的滚动条