我有这段代码,它可以很好地交替实际的行,但只悬停在“奇数”行上。
我正在使用以下代码:
<script type="text/javascript">
$(document).ready(function(){
//jQuery ready is quicker than onload
$(".stripeMe tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
$(".stripeMe tr:even").addClass("alt");
});
这是我正在使用的 css
#table tr.over td{background: #bcd4ec;}
#table tr.alt td {background: #ecf6fc;}
有什么想法吗?
最佳答案
你的 over style 被你的 alt style 覆盖了。你必须换线。
#table tr.alt td {background: #ecf6fc;}
#table tr.over td{background: #bcd4ec;}
现在 .alt
的优先级低于 .over
因为它的定义较早。
关于jquery - 悬停的 CSS 仅适用于 jQuery 的奇数行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6359985/