jquery - I cant make for loop work in function -



jquery - I cant make for loop work in function -

i trying create function puts text in abc div , loop want show 10 random text in div. cant create function work in loop, works 1 time stops. how can create more?

function myfunction() { settimeout(function () { var rand = math.floor((math.random() * 100) + 1); $("#abc").text(rand); }, 1000); } $('#start').click(function () { (var = 0; < 10; i++) { myfunction(); }; })

something this? — http://jsfiddle.net/pqmj2/

what need add together delay between each settimeout call.

function myfunction(i) { settimeout(function () { var rand = math.floor((math.random() * 100) + 1); $("#abc").text(rand); }, 1000 * i); } $('#start').click(function () { (var = 0; < 10; i++) { myfunction(i); }; })

what i'm doing here passing in value of i myfunction. way, there delay of 1 sec between each phone call i.e. 1000 * 1 = 1 second, 1000 * 2 = 2 seconds, 1000 * 3 = 3 seconds, , on.

jquery

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -