我有以下jQuery代码来替换图像时,鼠标悬停在上面,但它似乎并没有工作。下面的代码有什么问题?使用jQuery,你如何改变悬停在div内的图像?
$(function() {
$("div.delete img")
.mouseover(function() {
$(this).attr("src", "../../images/comment-hover-del.png");
})
.mouseout(function() {
$(this).attr("src", "../../images/comment-del.png");
});
});
这是我的HTML:
<div class="delete" id="26"><img src="../../images/comment-del.png" border="0"></div>
与您的问题无关的注释:HTML中的ID可能不以数字开头。 – RoToRa 2010-04-26 08:43:39