我有以下代码,我希望当用户将鼠标移到 div 上时它会显示,当鼠标移出 div 时它会隐藏。一切似乎都很好,但它不起作用。任何人都可以为我指出错误吗?
<script type="text/javascript">
$(document).ready(function () {
$(document).delegate('#myDiv', 'mouseover', function () { mouse_OverDiv(); });
$(document).delegate('#myDiv', 'mouseout', function () { mouse_OutDiv(); });
function mouse_OverDiv() {
$('#myDiv').css({ "visibility": "visible" });
}
function mouse_OutDiv() {
$('#myDiv').css({ "visibility": "hidden" });
}
});
</script>
<body>
<form id="form1" runat="server">
<div id="myDiv" style="visibility:hidden">
this is my div</div>
</form>
</body>