JavaScript method to implement timing closing of div: 1. Open the corresponding front-end code file; 2. Implement timing automatically through "onLoad=setTimeout("abc.style.display='none'",5000)" Just close the DIV layer prompt box.
The operating environment of this article: windows7 system, javascript version 1.8.5, DELL G3 computer
How to close div regularly with JavaScript ?
JS method to automatically close the DIV layer prompt box at a scheduled time
Here, JS is used to set the time to control whether the DIV layer with the specified ID is displayed, and an automatically closing prompt box can be realized , close it immediately when the time is up. This will make your web page more humane. The code is actually simpler than you think, just one line of code.
<title>自动关闭的DIV层</title> <body onLoad=setTimeout("abc.style.display='none'",5000)> <div id="abc" style="background:yellow;padding:20px; position:absolute; left:92px; top:38px; width:200px; height:169px; z-index:1"> 友情提示:本层5秒后会消失! </div>
Recommended study: "javascript basic tutorial"
The above is the detailed content of How to close divs regularly in JavaScript. For more information, please follow other related articles on the PHP Chinese website!