使用 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/