我需要更改鼠标悬停上的链接图像。我使用了下面的代码,但不起作用。也许问题出在图像源上,但我仍然无法找到他的代码有什么问题。如何更改鼠标上的链接图像上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