<script>
$(function(){
$("a.load").click(function (e) {
e.preventDefault();
$("#main").load($(this).attr("href"));
// alert("#"+($(this).attr("id")));
$("."+($(this).attr("class"))).css('border-bottom', 'solid 1px black');
$("."+($(this).attr("class"))).css('background-color', '#F5F5F5');
$("#"+($(this).attr("id"))).css('border-bottom', 'solid 2px white');
$("#"+($(this).attr("id"))).css('background-color', 'white');
});
});
</script>
尽管我的一个类的 :hover 属性在调用此函数后停止工作,但上述函数按预期工作。所以看起来 jQuery 的 CSS 方法正在重写 :hover 属性。有解决方法吗?
我尝试在函数末尾添加:
$("."+($(this).attr("class"))+":hover").css('border-bottom', 'solid 2px white');
但这没有帮助。
最佳答案
我刚刚发现了 !important 标签,它完成了工作!不再压倒一切!
border-bottom-color: white !important;
border-bottom-width: 2px !important;
background-color: white !important;
关于javascript - jQuery CSS 方法重写 :hover properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16763109/