我有一个jQuery效果,如果用户将鼠标放在回复图像上,图像将更改为其他图像。我遇到的问题是,当您将鼠标悬停在另一个对象上,该对象设置为addClass()作为回复图像时,此新回复图像在鼠标悬停时不会更改其图像。jQuery - addClass()mouseover
我的问题的演示: http://www.sfu.ca/~jca41/stuph/jQueryTest/jQueryTest.html
$(document).ready(function(){
$(".red").mouseover(function() {
$(this).css("color","red");
$(this).addClass("reply");
});
$(".red").mouseout(function() {
$(this).css("color","black");
$(this).removeClass("reply");
});
$(".reply").mouseover(function() {
$(this).css("background-image", "url(reply_h.png)");
});
$(".reply").mouseout(function() {
$(this).css("background-image", "url(reply.png)");
});
});
*注:*您应该链您的jQuery语句,如下所示:'$(this).css(“color”,“black”)。removeClass(“reply”);' – 2012-01-10 19:10:58
很酷。不知道你能做到这一点。刚做了修改。谢谢:) – Jon 2012-01-10 19:12:53