开发者

jQuery Async Plugin loop sequence

I am using http://mess.gene开发者_开发知识库zys.net/jquery/jquery.async.php for loop and need to reverse the order of the array(1,2,3) instead it goes from 3 to 1

Is there any way to change that from the code?


var someArray = [1,2,3],
    i = someArray.length - 1;

// Reverse processing
jQuery.whileAsync({
    delay: 100,
    bulk: 0,
    test: function() { return i >= 0 },
    loop: function() { 
        // Do something with the array
        i--;
    }
});

// Forward processing
i = 0;
var len = someArray.length;
jQuery.whileAsync({
    delay: 100,
    bulk: 0,
    test: function() { return i < len; },
    loop: function() { 
        // Do something with the array
        i++;
    }
});


Use this http://www.w3schools.com/jsref/jsref_reverse.asp reverse() function if that is what you need, maybe some code would be better explanation. cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜