<!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>
网友评论