即使 jquery 语句失败也执行回调
我有一个jquery语句如下:
$('.panel.col2, .panel.col3').fadeOut('fast', function(){
//SOME CODE
});
问题是这些元素并不总是存在,我需要它来执行回调,无论回调所属的语句是否成功。有什么解决方法吗?
I have a jquery statement as follows:
$('.panel.col2, .panel.col3').fadeOut('fast', function(){
//SOME CODE
});
The problem is that these elements do not always exist, and I need it to execute the callback regardless of the success of the statement the callback belongs to. Is there any workaround to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样的事情:
Try something like this:
听起来您希望在
fadeOut
的回调中运行一些代码,如果它们没有要淡出的元素,则在外部运行。这是一个想法,但我不知道你想要做什么的背景。It sounds like you want some code to run in the call back for
fadeOut
and outside if their are no elements to fade out. Here is an idea but I do not know the context of what you are trying to do.