所以我现在有这个:
$('#message_notice').click(function(){
$(this).fadeOut('slow');
});
$('#message_notice').delay(8000).fadeOut('slow');
我最终想做的是,如果单击一条消息,则继续并将其淡出。否则,X秒后自动淡出。
我可以选择其中之一,但如果我同时拥有两者(如我的示例中所示),则单击不起作用(只是延迟淡入淡出)。
我使用的是 jQuery 1.4.4。
最佳答案
您需要调用.stop(true)
在点击处理程序中取消您放入队列的 delay()
。
新代码应该如下所示
$('#message_notice').click(function(){
$(this).stop(true).fadeOut('slow');
});
$('#message_notice').delay(8000).fadeOut('slow');
关于javascript - jQuery:除非点击否则延迟淡入淡出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5274600/