如何在sequentialFade完成后调用函数

时间:2013-05-28 04:33:28

标签: jquery

sequentialFade:

(function sequentialFade (collection, speed) {
    collection.eq(0).fadeIn(speed, function() {
    if (!!collection.length) {
            sequentialFade(collection.slice(1, collection.length), speed);
        }
    }, next());
}($("#f1, #f2, #f3"), 400));

我的职能:

function next() {
    $('#line1').show(1000);
    $('#line1').animate({left: '10px'}, 1000);
}

在sequentialFade完成后如何调用next()函数?

1 个答案:

答案 0 :(得分:0)

试试这个,

var speed=5000;// for 5 second
(function sequentialFade(collection, speed) {
    collection.eq(0).fadeIn(speed, function() {
        if (collection.length) //remove !! from if condition
        {
            sequentialFade(collection.slice(1, collection.length), speed);
        }
    });
    next();//call this function outside 

}($("#f1,#f2,#f3"), 400));
function next() {
    $('#line1').show(1000);$('#line1').animate({left: '10px'}, 1000);
}