码迷,mamicode.com
首页 > Web开发 > 详细

Js onmouseover和onmouseout小特效

时间:2017-12-16 23:11:32      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:get   body   ref   doctype   lock   block   log   lin   ntb   

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<style>
    div{float:left;margin:20px;}
    #div1{width:100px;height:100px;background: #f00;}
    #div2{width:200px;height:200px;background:#ccc;display: none;}
</style> 
<script type="text/javascript">
    window.onload=function(){
        var oDiv1=document.getElementById("div1");
        var oDiv2=document.getElementById("div2");
        var timer=null;
        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>
</head>
<body>
    <div id="div1"></div>
    <div id="div2"></div>
</body>
</html>

 

Js onmouseover和onmouseout小特效

标签:get   body   ref   doctype   lock   block   log   lin   ntb   

原文地址:http://www.cnblogs.com/itsmart/p/8047784.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!