0
我正在使用jQuery
在图像的开启和关闭悬停之间进行切换。这是我的代码。 HTML与attr配合使用与mouseover()和mouseout()(图像交换)
<img class="commentImg" src="images/comments.png" data-swap="images/comment_hover.png" alt="">
jQuery的
$(".commentImg").hover(function() {
var swap = $(this).attr("data-swap");
$(this).attr('src', swap);
},
function() {
var swap = $(this).attr("data-swap");
$(this).removeAttr(swap);
});
的mouseover
工作正常,但mouseout
没有。你们能帮我吗?
是啊,你是对的:) – 2014-10-08 04:31:14
这工作。谢谢。 – 2014-10-08 04:31:55