当前位置: 代码迷 >> ASP >> 鼠标点击展开点击其他区域收缩如何操作的
  详细解决方案

鼠标点击展开点击其他区域收缩如何操作的

热度:164   发布时间:2012-03-12 12:45:33.0
鼠标点击展开点击其他区域收缩怎么操作的?
<a   style= "cursor:hand "   onfocus= "aaa128.style.display= 'block '; "   onblur= "if(aaa128.contains(document.activeElement))   this.focus();   else   aaa128.style.display= 'none '; "   onclick= "if(aaa128.style.display== ' ')   aaa128.style.display= 'none ';   else   aaa128.style.display= ' ';   "> 查看 </a>
<div   id= "aaa128 "   style= "display:none;border:#000   1px   solid "> 内容 </div>

如何让鼠标点击aaa128这个层之外的其他任何地方时,aaa128这个层自动隐藏呢?搞了半天才搞成这样,现在只能再点击查看才隐藏?不知道怎么回事

------解决方案--------------------
<a style= "cursor:hand " onfocus= "aaa128.style.display= 'block '; " onblur= "if(aaa128.contains(document.activeElement))

this.focus(); else aaa128.style.display= 'none '; " onclick= "if(aaa128.style.display== ' ') aaa128.style.display= 'none '; else

aaa128.style.display= ' '; "> 查看 </a>
<div id= "aaa128 " style= "display:none;border:#000 1px solid "> 内容 </div>
<script type= "text/javascript ">
<!--
document.body.onclick = function() {
var src = window.event.srcElement;
//alert(src.tagName);
if (window.event.srcElement != aaa128 && src.tagName != "A " && src.tagName != "INPUT ") {
aaa128.style.display = "none ";
}
}
-->
</script>
  相关解决方案