0

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

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

Thanks, B

asked Jan 21, 2010 at 17:22

3 Answers 3

4

try:

setTimeout(function(){document.getElementById("loading1").innerHTML="";}, 4000);
answered Jan 21, 2010 at 17:23
Sign up to request clarification or add additional context in comments.

Comments

4
function setHtml() {
 document.getElementById("loading1").innerHTML="";
}
setTimeout(setHtml, 4000);
answered Jan 21, 2010 at 17:23

2 Comments

Personally I would use an anonymous function. But for beginners this is clearer and easier to understand.
I agree. That was my reasoning.
4

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

setTimeout(function() { document.getElementById("loading1").innerHTML=""; }, 4000);
answered Jan 21, 2010 at 17:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.