我有这个代码:
$('.hotel_photo_select').fadeOut(500,function () { alert("Now all '.hotel_photo_select are hidden'"); });
只有当ALL .hotel_photo_select被淡入淡出(因此,隐藏)时,我才想呼叫该警报.
解决方法
您可以使用
promise()方法(该文档页面有一个很好的例子).
The .promise() method returns a dynamically generated Promise that is
resolved once all actions of a certain type bound to the collection,
queued or not,have ended.
应用于你的例子应该是这样的:
$.when($('.hotel_photo_select').fadeOut(500)) .done(function() { alert("Now all '.hotel_photo_select are hidden'"); });