我的页面中有一些 div,当用户拖动其中一个 div 时,div 会淡出。这是可行的,但 div 会在 6 秒后立即淡出。
$(function(){
$( ".comment-list.clearfix" ).draggable({axis: "x"},{
start: function() {
$(this).fadeOut(6000);
},
});
});
最佳答案
使用setTimeout()对于延迟,例如,
start: function() {
var $this=$(this);
setTimeout(function(){
$this.fadeOut(6000);
},5000); // 5 seconds timeout, for example
}
或使用delay()就像,
start: function() {
$(this).delay(5000) // 5 seconds delay, for example
.fadeOut(6000);
}
注意:您可以根据需要更改延迟间隔。
关于javascript - 立即淡出工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28939346/