samedi 31 janvier 2015

jQuery/JavaScript delay and display


I want to cycle through an array and display each element individually, and then remove it. Sort of like this fiddle, but I don't want it to go forever.


I tried using jQuery because I thought it would be easier, but I am clearly missing something. Can anyone help?


Here is my attempt, but it just goes straight to the last element in the array.



var list = [1,2,3,4,5,6];
var length = list.length;

for(i = 0; i < length; i++) {
$('#nums').html(list[i]).delay(750);
}


Oh, and I don't care if it's jQuery or vanilla JavaScript. Either is fine by me.





Aucun commentaire:

Enregistrer un commentaire