Javscript sleep emulation techniques

function pause(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis)
}
$("div.down").each(function(){

var self = $(this);

self.click();
pause(1000);

});

Untested

var stack = {
        delay: 1000,
        actions:[],
        run: function() {
                if (stack.actions.length) {
                        stack.actions.shift()();
                        setTimeout(stack.run, stack.delay);
                }
        }
};

$(elems).each(function(){
        var that = this;
        stack.actions.push(function(){
                $(that).dostuff();
        });
});

stack.run();

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>