zoukankan      html  css  js  c++  java
  • 延时提示框 setTimeout

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<title></title>
    		<style type="text/css">
    			#div1{
    				 50px;
    				height: 50px;
    				background: red;
    				float: left;
    			}
    			#div2{
    				 100px;
    				height: 100px;
    				background: blue;
    				float: left;
    				display: none;
    				margin-left: 10px;
    			}
    		</style>
    		<script>
    			window.onload = function(){
    				var oDiv1 = document.getElementById("div1");
    				var oDiv2 = document.getElementById("div2");
    				var timer = null;
    				oDiv2.onmouseover = oDiv1.onmouseover = function(){
    					clearTimeout(timer);
    					oDiv2.style.display = "block";
    				}
    				oDiv2.onmouseout = oDiv1.onmouseout = function(){
    					timer = setTimeout(function(){
    						oDiv2.style.display = "none";
    					},500);
    					
    				}
    				
    //				oDiv2.onmouseover = function(){
    //					clearTimeout(timer);
    //				}
    //				oDiv2.onmouseout = function(){
    //					timer = setTimeout(function(){
    //						oDiv2.style.display = "none";
    //					},500);
    //					
    //				}
    				
    			}
    		</script>
    	</head>
    	<body>
    		<div id="div1"></div>
    		<div id="div2"></div>
    	</body>
    </html>
    

      

  • 相关阅读:
    没有上司的舞会
    邮票面值设计
    小木棍
    简单的试炼
    区间质数
    加工生产调度
    泥泞的道路
    总数统计
    中庸之道

  • 原文地址:https://www.cnblogs.com/mingjixiaohui/p/5266907.html
Copyright © 2011-2022 走看看