我有这个
if(noDelay){
$(element).find("." + options.class).remove();
} else {
$(element).find("." + options.class).fadeOut().remove();
}
有没有一种方法可以避免重复句子并且只在满足给定条件时添加
fadeOut()
?我无法将
fadeOut()
移动到链的末尾,这可能会使事情变得更容易。我在想像
$(element).find("." + options.class).(if(noDelay) fadeOut()).remove();
提前致谢,
狮子座
最佳答案
没有您想要的任何文档,但是也许这对您有用:
$(element).find("." + options.class).fadeOut(noDelay ? 0 : 400).remove();
为什么选择400,因为fadeOut的默认持续时间为400毫秒。 (from documentation)
关于javascript - jQuery:如果在链中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8436751/