javascript - 显示第一个 div 并隐藏其余部分,然后在几秒钟后通过隐藏其余部分(包括第一个 div)显示第二个 div
问题描述
我需要通过隐藏 div 的其余部分来显示 div 1 的内容,几秒钟后隐藏第一个并显示第二个 div,几秒钟后通过在 jquery 中显示第三个 div 隐藏第二个 div 和第一个 div。
详细说明如果 div 1 显示隐藏 2nd 和 3rd div,然后通过隐藏 div1 和 div3 在 5 秒后显示 2nd div,然后通过隐藏 div1 和 div 2 在 5 秒后显示 3rd div。
div 的隐藏和显示应该在 5 secs.strong 文本之后
解决方案
要让您的页面等待几秒钟,然后执行某项操作,您需要在下面执行此操作
//create sleep function
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
//here you call the function with parameter the secods when you want to sleep you page. 1000 = 1s
sleep(5000);
//and here you alert an message after 5s
alert("hello!");
//here you can select the div and remove it or display it with js after the sleep
document.getElementById("myDIV").style.display = "none";
推荐阅读
- java - 如何更改这个泛型类,以便 main 方法可以工作?
- java - 尝试使用 Platform.runlater() 从另一个类更新 JavaFX 时出现空指针异常
- javascript - 如何验证登录页面的 websql 数据库中是否存在用户名和密码?
- javascript - 如何在 Javascript 中按名称删除兑现 - pwa
- flutter - 如何比较 Dart 中“is”运算符中的类型变量
- angular - 使用动态创建具有多个段的 SVG 圆
和 - laravel - 外键约束形成错误,Laravel
- javascript - 更新了关于获取一个字段值的旧问题的答案
- java - 在 Android 中过滤 - 代码有效但未按预期返回屏幕的问题
- c# - 是否可以将节点的 InnerXml 转换为新的节点集合?(C#)