开发者

Delaying Javascript

开发者 https://www.devze.com 2022-12-17 21:54 出处:网络
How do I delay JavaScript - I tried the following but it doesn\'t delay??: setTimeout(document.getElementById(\"loading1\").innerHTML=\"\", 4000);

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

setTimeout(document.getElementById("loading1").innerHTML="", 4000);
开发者_运维百科

Thanks, B


try:

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


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


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

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

精彩评论

暂无评论...
验证码 换一张
取 消