tags:

views:

52

answers:

3

Hi All,

How do I delay JavaScript - I tried the following but it doesn't delay??:

setTimeout(document.getElementById("loading1").innerHTML="", 4000);

Thanks, B

+3  A: 
function setHtml() {
  document.getElementById("loading1").innerHTML="";
}
setTimeout(setHtml, 4000);
jessegavin
Personally I would use an anonymous function. But for beginners this is clearer and easier to understand.
slebetman
I agree. That was my reasoning.
jessegavin
+2  A: 

try:

setTimeout(function(){document.getElementById("loading1").innerHTML="";}, 4000);
matpol
+3  A: 

You would want to put your code inside of a function:

setTimeout(function() { document.getElementById("loading1").innerHTML=""; }, 4000);
mkedobbs