sách gpt4 ăn đã đi

javascript - Trì hoãn hành động cho đến khi .each() hoàn thành

In lại Tác giả: Walker 123 更新时间:2023-11-30 10:00:43 27 4
mua khóa gpt4 giày nike

我有以下方法:

function animatePortfolio(fadeElement) {
fadeElement.children('article').each(function(index) {
$(this).delay(1000*index).fadeIn(900);
});
}

我想推迟一个 Action ,直到 .each() 完全完成。假设这是我需要使用的某个版本的延迟/ promise ,但不了解它在这种情况下的工作方式。

câu trả lời hay nhất

可以使用动画返回的promise对象

function animatePortfolio(fadeElement) {
fadeElement.children('article').each(function(index) {
$(this).delay(1000 * index).fadeIn(900);
}).promise().done(function() {
fadeElement.css('color', 'red')
});
}


animatePortfolio($('div'))
article {
display: none;
}


1

2

3

4

关于javascript - 推迟行动直到 .each() 完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31853023/

27 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress