日期:2014-05-17  浏览次数:20880 次

鼠标点击展开点击其他区域收缩怎么操作的?
<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>