我有以下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