clearTime

作者: Jadon7 | 来源:发表于2018-10-08 22:45 被阅读0次
<!DOCTYPE html>
<html>
<head>
    <title>clearTime</title>
</head>
<script type="text/javascript">
    window.onload=function()
    {
        var oDiv1=document.getElementById('div1');
        var oDiv2=document.getElementById('div2');
        var timer;

        oDiv1.onmouseover=oDiv2.onmouseover=function()
        {
            clearTimeout(timer);
            oDiv2.style.display='block';
        }
        oDiv1.onmouseout=oDiv2.onmouseout=function()
        {
            timer=setTimeout(function(){
                oDiv2.style.display='none';
            },500)  
        }
    }
</script>
<style type="text/css">
    #div1{
        margin: 20px;
        float: left;
        width: 50px;
        height: 50px;
        background: #333;
    }
    #div2{
        margin: 20px;
        float: left;
        width: 200px;
        height: 150px;
        background: #333;
        display: none;
    }
</style>
<body>
    <div id="div1"></div>
    <div id="div2"></div>
</body>
</html>

相关文章

网友评论

      本文标题:clearTime

      本文链接:https://www.haomeiwen.com/subject/sgjsaftx.html