首页 > Web开发 > 详细

js鼠标进入,延迟显示提示框

时间:2020-05-13 13:03:58      阅读:39      评论:0      收藏:0      [点我收藏+]

鼠标进入,延迟显示提示框

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>鼠标进入,延迟显示提示框</title>
        <style>
            .box{
                width: 500px;
                height: 500px;
                border: 1px solid black;
                position: relative;
            }
            #txt{
                display: none;
                width: 200px;
                height: 30px;
                line-height: 30px;
                border: 1px solid pink;
                position: absolute;
                right: 10px;
            }
        </style>
    </head>
    <body>
        <div class="box">
            鼠标进入,延迟显示提示框
        <p id="txt">
            提示框
        </p>
    </div>
    </body>
        <script>
            var obox=document.querySelector(".box");
            var otxt=document.getElementById("txt")
            var t;
            obox.onmouseover=function(){
                clearTimeout(t)
                t = setInterval(function(){
                otxt.style.display="block";
            },500)
            }
            obox.onmouseout = function(){
                clearTimeout(t)
                otxt.style.display="none"
            }
        </script>
    </html>

js鼠标进入,延迟显示提示框

原文:https://www.cnblogs.com/cupid10/p/12881003.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!