0
我有這個問題,我試圖設置我的延遲像下面的帖子: stackoverflow: jQuery: Can I call delay() between addClass() and such? 但它不適用於我。jQuery:addclass()之間的延遲()
$("#nav2").click(function() {
var notshown = $("#dropdown1", "#dropdown2");
var dropdown2 = $("#dropdown2");
if (dropdown2.hasClass("unselected") || dropdown2.hasClass("unshown")) {
notshown.removeClass('unshown').delay(1000).queue(function(){
var dropdown1 = $("#dropdown1");
var dropdown2 = $("#dropdown2");
var navwrapper = $("#navwrapper");
dropdown1.removeClass('unselected');
dropdown2.removeClass('unselected');
navwrapper.removeClass('unselected');
dropdown1.addClass('unselected').dequeue();
};
}else{
dropdown2.addClass('unshown');
navwrapper.addClass('unselected');
dropdown1.addClass('unshown');
}
});
與淡入/輸出也試過,但還是沒有動靜。
$("#nav1").click(function() {
var dropdown1 = $("#dropdown1");
var dropdown2 = $("#dropdown2");
var navwrapper = $("#navwrapper");
if (dropdown1.hasClass("unshown")) {
dropdown1.removeclass('unshown');
dropdown1.delay(200).fadeIn(500).delay(200);
navwrapper.removeclass('unshown');
} else {
dropdown2.addclass('unshown');
navwrapper.addclass('unshown');
dropdown1.delay(200).fadeOut(500);
dropdown1.addclass('unshown');
};
};
Any JS Fiddle link? – Varun
@Varun編輯於 – Chimposant
''它對我不起作用''怎麼辦? – Newd