javascript - Countdown for loop counting up -


the alert counting not down!

function loop() {     (var t = 32; t > 0; t--) {         (function (t) {             settimeout(function () {                 i_1(t);             }, 200);         })(t);     } } function i_1(amt) {     alert(amt); } 

you starting timeouts @ once. actual order executed depends on how events implemented internally in each browser.

give them different delays start 1 after other:

var time = 200; (var t=32;t>0;t--){   (function(t) {     settimeout(function() { i_1(t); }, time);     time += 200;   })(t); } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -