Yup, Ricardo's got it. In Javascript, everything runs in as it's called, and will not continue to the next action until the current one is complete. So if you have something like:
var num = 0; for (var i =0; i< 10000; ++i){ num += i; } alert(num); Num will properly display whatever the value of that works out to be. Also, your browser will hang for a while as it does the calculations. The only time this doesn't hold true, where processing is done outside the standard flow, is in a "thread" created by a setTimeout/ setInterval. [ function() ] | for() | alert() | setTimeout() ------- for() [w/callback] | | alert() callback() | done() On Jan 23, 11:57 am, Ricardo Tomasi <ricardob...@gmail.com> wrote: > Isn't it the same as doing this? > > $('span.countdown').each(function(){...}); > updateCounter(); > > The updateCounter function will only run after each() has returned/ > finished. > > On Jan 23, 2:43 pm, Ariel Flesler <afles...@gmail.com> wrote: > > > if( $('span.countdown').length ){ > > updateCounter(); > > > } > > > -- > > Ariel Fleslerhttp://flesler.blogspot.com > > > On 23 ינואר, 11:39, johannesf <johannes.foss...@gmail.com> wrote: > > > > Hi > > > > jquery is fantastic :-) > > > > My problem: I have a simple each-loop and after the loop I want to run a > > > js-function. > > > > How can I determine when the each-loop is done in a more elegant way then > > > this! > > > > ------------------------------------------------------------------------- > > > > var flag = false; > > > > $('span.countdown').each(function(){ > > > > flag = true; > > > > }); > > > > // when the loop is done, run 'updateCounter()' > > > if(flag == true){ > > > > updateCounter(); > > > > } > > > > all the best / johannes > > > > -- > > > View this message in > > > context:http://www.nabble.com/run-function-when-%27each%27-is-done%2C-how--tp... > > > Sent from the jQuery General Discussion mailing list archive at > > > Nabble.com.