[英]addClass(“test”) doesn't work - but css(“background”,“red”) does
Anyone know why? 有人知道为什么吗?
Here's the JS: 这是JS:
$(".screenshots .tab1").hover(function() {
$(".section1").addClass("test");
}, function() {
$(".section1").removeClass("test");
});
});
And the CSS: 和CSS:
.test {
background: black;
border: 1px solid #ffb75b;
background-color: #fffadb;
}
Maybe there is a css entry that overrules yours. 也许有一个CSS条目会否决您的条目。 Try this:
尝试这个:
background-color: #fffadb !important;
Maybe it is just a copy and paste error but you have a });
也许这只是复制和粘贴错误,但是您有一个
});
to much. 太多。 Should be:
应该:
$(".screenshots .tab1").hover(function() {
$(".section1").addClass("test");
}, function() {
$(".section1").removeClass("test");
});
See a live example: http://jsfiddle.net/wmD4E/ 查看现场示例: http : //jsfiddle.net/wmD4E/
Of course background: black
will have no effect because background-color: #fffadb;
当然
background: black
不会起作用,因为background-color: #fffadb;
overwrites it. 覆盖它。
I think it is because you have an extra }); 我认为是因为您有一个额外的}); at the end of your JS code.
在您的JS代码的末尾。 see working example here http://jsbin.com/adeye4/edit
在这里查看工作示例http://jsbin.com/adeye4/edit
Try specifying background once: 尝试一次指定背景:
.test {
border: 1px solid #ffb75b;
background-color: #fffadb;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.