[英]Using jQuery, how do I disable the click effect on the current tab?
我有一個正在進行動畫的菜單,但是我想在動畫發生時禁用單擊。
<div></div>
<div></div>
<div></div>
$("div").click(function() {
$(this).animate({height: "200px"}, 2000);
return false;
});
但是,我想在事件發生時禁用所有按鈕,並禁用單擊的div。
我正在考慮向單擊的div添加一個類,並將單擊僅放在沒有該類的div上:
$("div").not("clicked").click(function() {
$(this).animate({height: "200px"}, 2000).addClass("clicked");
return false;
});
但這似乎不起作用(我認為這在邏輯上是可行的)?
任何幫助表示贊賞。
干杯,
史蒂夫
$("div").click(function() {
if (!$(this).parent().children().is(':animated')) {
$(this).animate({height: "200px"}, 2000);
}
return false;
});
你可以做這樣的事情...
$(function() {
$("div").click(function() {
//check to see if any of the divs are animating
if ($("div").is(":animated")) {
alert("busy");
return;
}
//whatever your animation is
var div = $(this);
div.slideUp(3000, function(){ div.slideDown(1000); });
});
});
只要任何div當前未設置動畫,這都將為點擊設置動畫。 我很可能將所有這些div放到一個容器中,而不僅僅是引用div,因為它不僅會影響菜單,還會影響頁面上的更多內容,
動畫發生后如何禁用單擊的<div>? 我已經向div中添加了一個已單擊的類,但是執行以下操作似乎無效:
<div></div>
<div class="active"></div>
<div></div>
$("div").not('active').click(function() {
if (!$(this).parent().children().is(':animated')) {
$(this).animate({height: "200px"}, 2000);
}
return false;
});
我懷疑我在方法上缺少一些東西。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.