我在使用鼠标进入和离开功能时遇到了问题。我知道有一个.hover选项可以使用,但我想先将mouseenter/mouseleave功能实现。
我看到的情况是,我打开了Chrome并检查了图像,它显示src文件正在更改,但我没有看到明显的变化。请问有人可以帮忙吗?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
<title></title>
<script src="jquery-1.4.3.min.js" type="text/javascript"></script>
</head>
<body>
<img id="menuHome" src="m_home.gif" />
<script type="text/javascript">
$(document).ready(function() {
$("#menuHome").mouseenter(function() {
$(this).attr({ src: 'm_home_roll.gif' });
});
$("#menuHome").mouseleave(function() {
$(this).attr({ src: 'm_home.gif' });
});
});
</script>
</body>
</html>
$("#menuHome").hover( function() { $(this).attr({ src: 'm_home_roll.gif' }); } ,function(){ $(this).attr({ src: 'm_home.gif' }); }); });
- george9170