在使用animate()方法时,发现鼠标连续离开悬停几次,div(id=box)会运动几次,如何让鼠标悬停一次div就运动一次,而不是像带记忆一样悬停几次就运动几次。
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#box").mouseover(function(){
$("#box").animate({height:"300px"},"slow");
});
$("#box").mouseout(function(){
$("#box").animate({height:"100px"});
});
});
</script>
</head>
<body>
<div id="box" style="background:#98bf21;height:100px;width:100px;margin:6px;">
</div>
</body>
</html>
用mouseenter
没看清题目,你试试这样可以吗