setTimeout inside $.each()
ok, so I've got this code: $(this).find('article.loading').each( function(i) { var el = this; setTimeout(function () { $(el).replaceWith($('#dumpster article:first')); }, speed); }); I want to replace each element with another but I want a delay between each replace. I can't figure out why this isn't working, it just replaces all of them after one timeout. Any ideas? Thanks. You are looping through the elements and adding a timer to each with the same configuration. Essentially a new timer is instantly set up for each element. On the first tick of all the timers the elements are updated. The