setTimeout ignores timeout? (Fires immediately)
I think you should use setTimeout(doFade, 500);
or setTimeout("doFade()", 500);
setTimeout(doFade(), 500);
This line says "execute doFade()
, then pass whatever value it returns to setTimeout
, which will execute this return value after 500 milliseconds." I.e., you're calling doFade()
right there on the spot.
Skip the parentheses to pass the function to setTimeout
:
setTimeout(doFade, 500);
You need to get rid of the parentheses on doFade()
.
The parentheses invoke the function instantly.
Just use this in stead: doFade