0

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

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

Thanks, B

3 Answers 3

4

try:

setTimeout(function(){document.getElementById("loading1").innerHTML="";}, 4000);
Sign up to request clarification or add additional context in comments.

Comments

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

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);

Comments

Your Answer

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.