<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
var arry =[[101,"安徽省"]];
var arraySubRegion=new Array();
arraySubRegion[101]=[[10101,"合肥"],[10102,"芜湖"]];
window.onload = function()
{
var div_first = document.createElement("div");
div_first.id = 'first_div';
div_first.style.display = 'none'
div_first.onmouseout = function()
{
this.style.display = 'none'
}
 with(div_first.style){
  width="300px";
  height="300px"
  position="relative";
  border="1px solid #f93";
  }
  document.body.appendChild(div_first)
}
function dis(obj)
{
document.getElementById('first_div').style.display = 'block';

var id = obj.id;
var subs = arraySubRegion[id];
var input = ""
for(var i=0;i<subs.length;i++)
{
var regions = subs[i];
if(document.getElementById(regions[0]))
{
return;
}
var div = document.getElementById('first_div')
var s = document.createElement("span");
var ipt = document.createElement("input");
var label = document.createElement("label");
ipt.type = "checkbox";
ipt.id = ""+regions[0]+"";
label.innerText = ""+regions[1]+"";
div.appendChild(s);
s.appendChild(ipt);
s.appendChild(label);
}
}</script>
<title>无标题文档</title>
</head><body>
<a href="#" onclick="dis(this)" id="101">安徽省</a>
</body>
</html>
我鼠标移出div事件是隐藏 
但是div里面createelement后 移到里面内容时候也隐藏了 
这样的问题怎么处理?
 
目的是移出时div隐藏
应该如何处理

解决方案 »

  1.   

    //div_first.onmouseout = function()
    div_first.onmouseleave = function()
    IE下这样就行了。如果考虑其它浏览器的话,给你建的SPAN和INPUT添加鼠标事件,让它们显示div_first
      

  2.   

    div_first.onmouseleave = function()
    IE下这样就行了。
    (这个可以)
    如果考虑其它浏览器的话,给你建的SPAN和INPUT添加鼠标事件,让它们显示div_first
    显示之后就不会隐藏了