I have wrote this simple code to make a basic slideshow for my website. This code works fine for a while but after that it starts malfunctioning, I mean the image don't load appropriately, the same image suddenly pops ups and fades and then slowly appears back again. I though something could be wrong withe the SetTimeOut timing, but I've played with it a alot and it didn't solve my problem:
var x = 1;
function F() {
$('#Left').html("<img src='Images/" + x + ".jpg' />").fadeOut(0).fadeIn(1000).delay(5000).fadeOut(1000);
if (x < 3) { x++;}
else { x = 1; }
setTimeout("F()", 7000);
}
My question is what could be wrong with the simple code and how could I fix it or improve it.