想要在我的網站上顯示另一個圖像onmouseover和onmouseout。我有以下幾點:更改圖像onmouseover和onmouseout事件在IE中工作,但不在Chrome/FireFox中工作
<img src="@(Model.ThumbPath)" alt='@Model.Description'
onmouseover='iconMouseOver(this,"@Model.ThumbInvPath")'
onmouseout='iconMouseOut(this,"@Model.ThumbPath")'/>
JavaScript調用的方法:
function iconMouseOver(targetImg, replaceImg) {
$(targetImg).attr('src', replaceImg);
}
function iconMouseOut(targetImg, replaceImg) {
$(targetImg).attr('src', replaceImg);
}
上面的代碼在IE,但沒有任何其他瀏覽器。 (我知道,對嗎?通常情況是相反的)。顯示圖像,但鼠標懸停/懸停效果不起作用。 我錯過了什麼?
預先感謝您!
你知道,如果iconMouseOver /輸出事件甚至還讓在其他瀏覽器叫什麼名字? – JohnFx
寫上「return;」在函數結束時。未經測試但可能有效。 –
什麼是呈現的HTML? – TheVillageIdiot