您可以使用jQuery
動畫的callback
,並且可以使用下面的generic
方法來實現此目的以減少代碼。
function animateFade(elm, timers, cb) {
var index = 0;
var animateFn = function() {
if(timers.length > index) {
var timer = timers[index++];
elm.delay(timer[0]).fadeIn(timer[1], animateFn);
} else if(cb && typeof cb === 'function') {
cb();
}
};
animateFn();
}
// Change the timer values here
animateFade($('.learnwhat'), [[500, 1500], [2000, 500]);
animateFade($('.seeresults'), [[5000, 1500], [500, 500]);
animateFade($('.personalsolution'), [[9000, 1500], [500, 500]);
// or even if you want to chain them one after another
animateFade($('.learnwhat'), [[500, 1500], [2000, 500], function() {
animateFade($('.seeresults'), [[5000, 1500], [500, 500], function() {
animateFade($('.personalsolution'), [[9000, 1500], [500, 500]);
});
});
我們應該想象這個標記嗎? –
@AndreiGheorghiu這個標記幾乎沒有關係 – meagar
@AndreiGheorghiu我只是做簡單的fadeIns?你想看到內容? –