我有一個.box
股利,並點擊它展開。防止點擊觸發,如果用戶cliks動畫
問題是,如果你快速點擊多次在該div上,點擊事件將觸發新的動畫和動畫將運行每一次點擊。
HTML
<div class="box">
<div class="title">
<label>Some title</label>
</div>
<div class="text">
<label>Some text that is longer then the title text</label>
</div>
</div>
JQuery的
$('.box').toggle(function() {
$(this).attr("selected", "true");
$(this).animate({"height": "529px", "width": "460px"}, "slow");
},function() {
$(this).animate({"height": "163px", "width": "220px","z-index":"10"}, "slow");
});
我想以某種方式禁用點擊直到動畫完成一次。
這可能嗎?
Click fast many times on the yellow div。
僅供參考..切換事件處理程序已在jQuery的1.8和r棄用emoved在jQuery 1.9 http://api.jquery.com/toggle-event/ – 2013-03-03 22:27:32
@wirey什麼是替代切換呢? – Vucko 2013-03-03 22:28:56
切換隻是綁定到點擊事件 - 所以你可以綁定到點擊事件手處理它在那裏 – 2013-03-03 22:35:16