当前位置: 代码迷 >> ASP.NET >> 关闭层的有关问题
  详细解决方案

关闭层的有关问题

热度:9162   发布时间:2013-02-25 00:00:00.0
关闭层的问题
问个问题,当我鼠标点击一个层的外面时   关闭该层
这个功能是怎么实现的

------解决方案--------------------------------------------------------
obj = event.srcElement;
if (obj != null && obj.id != 'a ')
{
document.getElementById( 'a ').style.display= 'none ';
}
------解决方案--------------------------------------------------------
document.onmousedown=function()
{
obj = event.srcElement;
if (obj == null || obj.id== 'a ')
{
return;
}
while (obj=obj.parentNode)
{
if (obj.id == 'a ')
{
return;
}
}
document.getElementById( 'a ').style.display= 'none ';
}
  相关解决方案