0

I'm trying to display the process 'slowly' by adding a setTimeOut()

for (i = 0; i < 10; i++){
    setTimeout(function(){$("#result").prepend('dom<br/>')},2000);
}

Well, it doesn't work still, the dom process would display instantly after 2 second. What I want to do is 'see' the process of dom change, it would be like linux process file effect.

what should I do?

Weijing Jay Lin
  • 2,991
  • 6
  • 33
  • 53

1 Answers1

1

I would recommend separating functions and use setInterval

OR use 'for ~' for initializing the timing like below.

for (var i = 0; i < 10; i++) {
    setTimeout(function(){
        $("#result").prepend('dom<br/>');
    }, 2000 + 2000 * i);
}
Inpyo Jeon
  • 220
  • 1
  • 7