Can someone explain why the rows in the console are appending all in one time? I want them to get append one by one. row is an array of strings in the program and here is the code:
var dodajRed = function(redenBroj) {
setTimeout(function() {
$('.console').append('<p>' + row[redenBroj] + '</p>');
}, 1500);
}
dodajRed(0);
dodajRed(1);
dodajRed(2);
I want the rows to appear one by one with 1500ms delay
, but instead I get all rows appeared after 1500ms
.
There are lots of ways to do this. One possible solution is adjust your timeout:
You could also setup a promise chain, but you'd need an external library or browser that supports ECMAScript 6.