【发布时间】:2014-03-13 11:48:42
【问题描述】:
在 jquery 中我们使用延迟方法。但是我可以用什么来延迟 javascript 的 css 呢?
document.querySelector(".alert_display").style.display = "block";
我试过这样:
setTimeout(function(){
document.querySelector(".alert_display").style.display = "block";
},5000);
但似乎方法不对?
更新:
我发现了我的问题:
document.querySelector(".img-ball").style.animationPlayState = "running";
setTimeout(function(){
document.querySelector(".alert_display").style.display = "block";
},5000);
setTimeout(function(){
setTimeout(function(){
jconfirm("DO you want to go for next Questions?");
}, 200);
}, 500); // the '500' here is the problem was occurred and changed to 5000 then its okay now
知道吗,为什么会这样?
【问题讨论】:
-
为什么看起来不对?
-
应该是延迟了。
-
你能在小提琴中重现你的问题吗?
-
您确定
.alert_display在调用此代码之前已设置为display:none? -
您的代码运行良好:jsfiddle.net/ca7eM
标签: javascript