使用jQuery表操作器对表中的每一行进行排序并给出样式。
问题: 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>
发布于 2015-05-06 09:34:16
以下是IE <9的表行样式:
$(document).ready(function() {
$('#myTable')
.tablesorter({ widgets: ['zebra'] })
.bind('sortEnd', function(){
$("#myTable").trigger("applyWidgets");
});
}
);
对于其他浏览器,下面的内容会启动并覆盖上面的样式:
.tablesorter tbody tr:nth-child(odd) {
background-color: #faf4e2;
}
https://stackoverflow.com/questions/30064791
复制相似问题