我有两个名为“箭头”和“内”的div。我试图在点击div时控制动画滑动功能,但一直不幸。在用户停止点击div仍然滑动后,点击“arrow”div上非常快的速度时,问题很明显。我在短暂的延迟下设置了动画功能,但我仍然遇到延迟。这里是我的示例代码:Jquery-如何控制点击按钮上的动画功能?
<script language="javascript" src="http://code.jquery.com/jquery-1.5.2.js"></script>
<script language="javascript">
$(document).ready(function() {
var out = 0;
$("#arrow").click(function(){
if(out==0)
{
$("#inner").animate({marginRight: "0px"}, 500);
out=1;
}
else
{
$("#inner").delay(400).animate({marginRight: "-100px"}, 500);
out=0;
}
});
});
</script>
<div style="background-color: rgb(204, 204, 204); height: 300px; width: 300px; overflow: hidden; position: relative;">
<div id="inner" style="height: 100px; width: 150px; background-color: rgb(0, 204, 102); float: right; margin-right:-150px;" >Form is here</div>
<div id="arrow" style="height: 100px; width: 50px; background-color: rgb(255, 0, 0); float: right; cursor: pointer; position: absolute; top: 0; right: 0;" >Arrow is here</div>
</div>
1)使用1.7.1或最新 - 2)为什么不切换? – mplungjan 2012-03-24 06:49:09
嘿使用此 - http://jsfiddle.net/paL6M/2/(使用手风琴),但你去的**版本是在这里:** http://jsfiddle.net/VuzdM/1/驻留在这里 - 让我知道如果这有帮助,我不会看到任何滞后让我知道我可以将它设置为回答+ 1 for @mplungjan提及使用最新的Jquery版本,欢呼! – 2012-03-24 06:55:05