jsFiddle:http://jsfiddle.net/KH8Gf/27/Retardo cada iteración del bucle por un tiempo determinado
Código:
$(document).ready(function()
{
$('#expand').click(function()
{
var qty= $('#qty').val();
for (var counter = 0; counter < qty; counter++)
{
$('#child').html($('#child').html() + '<br/>new text');
}
});
});
¿Cómo se puede retrasar Yo cada iteración del bucle por un tiempo determinado?
He intentado lo siguiente sin éxito:
setTimeout(function(){
$('#child').html($('#child').html() + '<br/>new text');
},500);
y
$('#child').delay(500).html($('#child').html() + '<br/>new text');
Debe moverse 'setTimeout (al lado, 500); 'en el bloque if. –
@JosephSilber - corregido - thx. Tratando de escribir demasiado rápido (la carrera para publicar en SO me lo hace a mí). – jfriend00
@ jfriend00 +1 y funcionó. Ni siquiera había terminado de escribir a la mitad :( – gideon