【发布时间】:2014-12-02 15:48:12
【问题描述】:
我正在使用jQuery 在悬停时切换图像。这是我的代码。
HTML
<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 不行。你们能帮帮我吗?
【问题讨论】:
标签: javascript jquery html css attr