做了个例子,不知道是不是lz想要的效果:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
var out;
function a(){
div1.style.display="none";
}
function show_div(){
div1.style.display="block";
}
function smalldiv(){
out=window.setTimeout("a()",10);
if(event.srcElement.id!="div1")
event.srcElement.style.backgroundColor="#cccccc";
}
function overdiv(){
window.clearTimeout(out);
if(event.srcElement.id!="div1")
event.srcElement.style.backgroundColor="#aaaaaa";
}
</script>
</head>
<body>
<div id=div1 style="width:200px;height:210px;background-color:#cccccc;display:none" onMouseOut="smalldiv()" onMouseOver="overdiv()">
<div style="border:1px solid blue;width:100%;height:30px;" id="menu1"></div>
<div style="border:1px solid blue;width:100%;height:30px;" id="menu2"></div>
</div>
<input type=button id=btn1 value="显示div" onclick="show_div()">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
var out;
function a(){
div1.style.display="none";
}
function show_div(){
div1.style.display="block";
}
function smalldiv(){
out=window.setTimeout("a()",10);
if(event.srcElement.id!="div1")
event.srcElement.style.backgroundColor="#cccccc";
}
function overdiv(){
window.clearTimeout(out);
if(event.srcElement.id!="div1")
event.srcElement.style.backgroundColor="#aaaaaa";
}
</script>
</head>
<body>
<div id=div1 style="width:200px;height:210px;background-color:#cccccc;display:none" onMouseOut="smalldiv()" onMouseOver="overdiv()">
<div style="border:1px solid blue;width:100%;height:30px;" id="menu1"></div>
<div style="border:1px solid blue;width:100%;height:30px;" id="menu2"></div>
</div>
<input type=button id=btn1 value="显示div" onclick="show_div()">
</body>
</html>
<div style="width:200px;height:210px;" onMouseOut="smalldiv()">
--->>>
<div style="width:200px;height:210px;" onmouseleave="smalldiv()">
你测过吗?什么效果?我怎么看不出来?.......
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
function a(){
div1.style.display="none";
}
function show_div(){
div1.style.display="block";
}
function smalldiv(){
if(event.toElement&&event.toElement.tagName!="DIV")
a();
}
function overdiv(obj){
obj.style.backgroundColor="#aaaaaa";
}
</script>
</head>
<body>
<input type=button id=btn1 value="显示div" onclick="show_div()">
<div id=div1 style="width:200px;height:210px;background-color:#cccccc;display:none" onMouseOut="smalldiv()">
<div style="border:1px solid blue;width:100%;height:30px;" id="menu1" onMouseOver="overdiv(this)" onmouseout="window.event.cancelBubble = true;this.style.backgroundColor='#cccccc'"></div>
<div style="border:1px solid blue;width:100%;height:30px;" id="menu2" onMouseOver="overdiv(this)" onmouseout="window.event.cancelBubble = true;this.style.backgroundColor='#cccccc'"></div>
</div>
</body>
</html>