在下面的代码中,一旦鼠标移出,鼠标再次悬停就不起作用了,解决这个问题的办法是什么
<!DOCTYPE html>
<html>
<head>
<style>
/* div { background:#def3ca; margin:3px; width:80px;
display:none; float:left; text-align:center; }*/
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div id="playControls" style="position:absolute; bottom:0px; left:0px; right:0px;color:blue;">
Mouse over me
</div>
<script>
$(document).ready(function() {
$("#playControls").mouseover(function () {
alert('here');
$("div:eq(0)").show("fast", function () {
/* use callee so don't have to name the function */
$(this).next("div").show("fast", arguments.callee);
});
});
$("#playControls").mouseout(function () {
alert('here');
$("div").hide(2000);
});
});
</script>
</body>
</html>发布于 2010-06-15 18:20:01
这一行隐藏了页面上的所有div:
$("div").hide(2000);我不认为这是你想要的。它还将隐藏处理mouseover/mouseout的div。
我想你的意思是:
$(this).next("div").hide(2000);这将只隐藏您想要的div。
发布于 2010-06-15 18:20:28
使用hover函数。它是专门为这种使用模式制作的。
发布于 2010-06-15 18:24:08
$("#playControls").mouseout(function () {
alert('here');
$("div").hide(2000);
});在这部分代码中,当您将鼠标移出div#playControls时,您将隐藏所有的div。不能触发div的mouseover事件的原因是因为div是隐藏的。
https://stackoverflow.com/questions/3044257
复制相似问题