延时提示框 setTimeout
2016-03-11 19:22
274 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> #div1{ width: 50px; height: 50px; background: red; float: left; } #div2{ width: 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>
相关文章推荐
- 了解和熟悉操作系统
- 实验 0 了解和熟悉操作系统
- 《Java高级程序设计》第一周作业
- 欧几里得&扩展欧几里得
- 喷水装置(一)
- RecyclerView 的研究和使用
- 剑指offer 二进制中1的个数
- 【私人记录】东查查西查查一下午搞定了SVM配置MATLAB2012
- JS堆栈与拷贝
- 实验0 了解和熟悉操作系统
- snvserve不是内部命令
- 第二天可的总结
- iOS之如何判断已经过了多长时间
- nandflash裸机程序分析
- HDU 5428 The Factor 分解因式
- Set和Map
- POJ 2528 Mayor's posters 线段树+离散化
- ASCII码排序
- Keil 4软件入门
- final关键字总结