我需要更改鼠標懸停上的鏈接圖像。我使用了下面的代碼,但不起作用。也許問題出在圖像源上,但我仍然無法找到他的代碼有什麼問題。如何更改鼠標上的鏈接圖像上jquery
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Edit Document</title>
<script src="../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#lnkEdit").hover(
function() {
this.src = this.src.replace("../images/edit_off.gif", "../images/edit_on.png");
},
function() {
this.src = this.src.replace("../images/edit_on.png", "../images/edit_off.gif");
}
);
});
</script>
</head>
<body>
<form method="post" action="Hover4.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTkwNjIyODQxZGR6kotcsbIsWRfokZrzasCtfPi0dxz4MBWWh9VxSJ6R0Q==" />
</div>
<div>
<a id="HyperLink1" href="Hover4.aspx"><img src="../images/edit_off.gif" alt="HyperLink" /></a>
</div>
</form>
在此先感謝。
是,你是對的。我忽略了第1項。 我使用了您的代碼,但仍然無法在懸停時進行更改。 – blueDroid 2010-07-03 03:49:16
對不起,我錯過了'MyImage'的''''。現在已經修復了。 – casablanca 2010-07-03 04:01:27
感謝您的代碼。它適用於如果我使用圖像按鈕,但仍然不適用於超鏈接。超鏈接運行在服務器端 HyperLink asp:HyperLink> 並且不讓我使用id =「MyImage」,因爲它已經使用id =「Hyperlink1」 任何其他建議? 感謝您的幫助。 –
blueDroid
2010-07-06 13:44:40