做了个例子,不知道是不是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>
解决方案 »
- window对象中的open()方法
- js中遍历list出错
- 我是新手,求几个关于JaveScript代码的写法,最好有注释,谢谢了
- createElement一个元素被拦截了
- JS 没权限问题
- javascript初学者遇到难题
- JavaScript脚本,运行过程中出现“脚本大量运行,可能使浏览器速度变慢“的提示
- 如何使下拉框失效,不改变值,就想文本筐有readonly一样,但提交后又能取到值
- 页面内有两个框架,分别为leftFrame 和mainFrame,leftFrame中有form1. mainFrame用于显示以form1传来的数据查出的数据,即如何在两个框
- 为什么我的setInterval不能循环执行
- object与 Object , number 与Number 区别是什么?
- 日期判断的问题,请各位给个思路
<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>