Home > Web Front-end > JS Tutorial > JS delayer

JS delayer

不言
Release: 2018-04-10 11:48:26
Original
2656 people have browsed it

The content introduced in this article is the code of js delayer. Now I share it with everyone. Friends in need can refer to it


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="系统CSS初始化.css">
    <style>        #p1{            width: 50px;            height: 50px;            background: rebeccapurple;            float: left;            margin: 20px;
        }        #p2{            width: 200px;            height: 200px;            background: #555555;            float: left;            margin: 20px;            display: none;
        }
    </style>
    <script>        window.onload=function () {            var op1=document.getElementById("p1");            var op2=document.getElementById("p2");            var timer=null;            op1.onmousemove=function () {                clearTimeout(timer);                op2.style.display="block";
            }            op1.onmouseleave=function () {               timer= setTimeout(function ()
                {                    op2.style.display="none";
                },500)

            }            op2.onmousemove=function () {                clearTimeout(timer);
            }            op2.onmouseleave=function () {                timer=setTimeout(function () {                    op2.style.display="none";
                },500)

            }
        }
    </script>
</head>
<body>
<p id="p1";></p>
<p id="p2"></p>
</body>
</html>
Copy after login

                           

##

The above is the detailed content of JS delayer. 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