jQuery的鼠标悬停/鼠标移开
问题描述:
在下面的代码,一旦鼠标移出完成鼠标一遍不行的,究竟是什么jQuery的鼠标悬停/鼠标移开
<!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>
答
工作都是围绕这条线隐藏在网页上的所有div:
$("div").hide(2000);
我不认为这是你想要的。它也会隐藏处理mouseover/mouseout的div。
我想你的意思是:
$(this).next("div").hide(2000);
这将隐藏只有你想要的股利。
答
$("#playControls").mouseout(function() {
alert('here');
$("div").hide(2000);
});
在你的代码的这部分,当你mouseout的div#playControls时你隐藏所有div。你无法触发div的mouseover事件的原因是因为div是隐藏的。
不,我不想要这个,但我应该能够检索到div,它是如何完成的 – Hulk 2010-06-15 10:24:21
这是不是很清楚预期的行为是什么。你能解释一下你想在mouseover/mouseout上发生什么吗? – 2010-06-15 10:26:50
在鼠标悬停的div,该div应该是可见的其他隐藏div – Hulk 2010-06-15 10:31:20