Home > Web Front-end > JS Tutorial > body text

How to close divs regularly in JavaScript

藏色散人
Release: 2021-10-18 14:05:30
Original
2346 people have browsed it

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.

How to close divs regularly in JavaScript

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=&#39;none&#39;",5000)>
<div id="abc" style="background:yellow;padding:20px;
position:absolute; left:92px; top:38px;
width:200px; height:169px; z-index:1">
友情提示:本层5秒后会消失!
</div>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template