我写了下面的jquery来将斑马剥离应用到表格中的某一行。这在Chrome和Firefox中运行良好,但在IE8中无效。 W
<script>
$(document).ready(function()
{
$("tr.alt:even").css("background-color", "#f0f8ff");
$("tr.alt:odd").css("background-color", "#fcfceb");
});
</script>
这是HTML
<tr class="alt">
<td class="status"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status></td>
<td class>Received</td>
</tr>
答案 0 :(得分:3)
(在IE 7,8中测试......)
修复您的标记,它会完美无缺:class="status
&lt; - 缺少"
<td class>
=无效的attr
<table>
<tr class="alt">
<td class="status"></td>
<td>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td>Received</td>
</tr>
<tr class="alt">
<td class="status"></td>
<td>Received</td>
</tr>
</table>
或者它应该是:
<table>
<tr class="alt">
<td class="status"></td>
<td class="Received"></td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class="Received"></td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class="Received"></td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class="Received"></td>
</tr>
<tr class="alt">
<td class="status"></td>
<td class="Received"></td>
</tr>
</table>
我不知道,两种作品都选择了你的选择
答案 1 :(得分:0)
<style type="text/css">
tr.odd
{
background:fcfceb;
}
tr.even
{
background:f0f8ff;
}
tr.zero
{
background-color:#FFE4E1;
}
</style>
<script>
jQuery(function($) {
$("tr.alternateColor:odd").addClass("odd");
$("tr.alternateColor:even").addClass("even");
</script>
终于让它运行了。我在IE中遇到了CSS问题