日期:2014-05-16  浏览次数:20352 次

关于jquery 怎样让 animate不多次执行呢
提供一段w3c里面的教程
http://www.w3school.com.cn/tiy/t.asp?f=jquery_animation


<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript"> 
$(document).ready(function(){
  $("#start").click(function(){
  $("#box").animate({height:300},"slow");
  $("#box").animate({width:300},"slow");
  $("#box").animate({height:100},"slow");
  $("#box").animate({width:100},"slow");
  });
});
</script> 
</head>
 
<body>

<p><a href="#" id="start">Start Animation</a></p>

<div id="box"
style="background:#98bf21;height:100px;width:100px;position:relative">
</div>
 
</body>
</html>

大家可以先打开看一下,当点击Start Animation一次的时候 有有一个动画出现。

当你快速点击5次的时候,这个动画就会显示5次,请问如果避免这种情况呢。

因为我要做一个类似 www.yilunet.com 首页这个滑动的效果。我的站上面当鼠标在三个图上面滑动多次后 页面就不听的动,请高手指点如何才能做到类似www.yilunet.com这个的华东效果

------解决方案--------------------
给单击事件做个判断,
JScript code

$("#button").click(function() {
    if(!$("#div:animate")) {
        $("#div").animate();
    }
}