所以它改变背景图像,但不改变背景颜色。 无论如何照顾指出我的代码中的问题?背景颜色不变?
的JavaScript:
$("#menu a").hover(function() {
$(this).addClass("hover");
}, function() {
$(this).removeClass("hover");
});
CSS:
.hover {
background-color: white;
background-position: top center;
background-image: url("img/dot.png");
background-repeat: no-repeat;
color: red;
}
你需要显示非悬停默认类。 – 2012-02-07 14:57:42
也许是其他的CSS规则重写它在页面上。 – ShankarSangoli 2012-02-07 14:57:51
你不必使用'$ .hover()';您可以使用':hover'伪类在纯CSS中执行此操作。 – Bojangles 2012-02-07 14:58:11