关于用js添加的层的问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 05:57:37
div=document.createElement("DIV");
div.id="div1";
div.style.top=oh+5+"px";
div.style.left=ow+"px";
div.style.width=50;
div.style.height=200+"px";
div.style.zIndex=1;
div.style.position="absolute";
div.style.background="yellow";
div.style.display="";
div.innerHTML='层操作测试';
doc.body.appendChild(div);

我用以上js语句添加了一个层,我想给这个层添加个onmouseout的属性,也就是说想让鼠标移出后层消失,也就是下拉菜单的效果。可是怎么也添加不进去,求解……
我写了个隐藏层的代码
function hiddiv(){
var div=document.getElementById("div1");
div.style.display="none";
}

并且也调用了div.onmouseout="hiddiv()";
但是不管用 求解~~~~~~~~~~~~~

<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript">
function MenuOn(x){
obj=document.getElementById("submenu"+x).style.visibility="visible";
}
function MenuOff(x){
obj=document.getElementById("submenu"+x).style.visibility="hidden";
}
</script>
<title>jsframe.jsp</title>
</head>
<body>
鼠标移上去看看我吧!!!<input type="button" value="1" onmouseover="MenuOn(this.value)" onmouseout="MenuOff(this.value)" size="100">
<div id="submenu1" style="visibility: hidden">
<table bgcolor="red" width="200" height="100"><tr><td>我是表格,可以在我的里面写内容噢!</td></tr></table>
</div>
别只看它