See the code below…it changes the image after the page load + 8 sec and then keep on changing every 1 second.
setInterval(function(){
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/wtrhwt.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/t8yejty.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/t2tgw8.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/45234.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/14134.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/124t234grq.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/frbvqw34.jpg');
setTimeout(function(){
$('#person1').attr('src', 'lastwavewinnerimages/14tqwrbfws.jpg');
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}, 8000);
This loop execute after 8 sec. I want it to start it from the very first second when the page load. How to do it.
setInterval waits for the 8000 to pass before the function is first called, also you might wanna refactor the code like so: