div1浮动在页面的最上面,我想点击页面的其他部分,使div消失,应该是触发什么事件? rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 code=JScript][/code] document.onclick= document.getElementById("divId").style.display="none"[ document.onclick= document.getElementById("divId").style.display="none" .ccc{display:none;}onclick使div的className为ccc document.onclick= document.getElementById("divId").style.display="none"或者 document.onclick= document.getElementById("divId").style.visible="hiden"但两种多少有点区别 <a hideFocus href="###" onclick="setDiv(this)">点击这里</a><div id="divbox" style="border:1px red dashed; display:none; width:301px; height:48px"></div> <script language=JavaScript> function setDiv(_this){ if (document.getElementById("divbox").style.display=='none') showDiv(_this) else hidDiv()} function showDiv(_this){ document.getElementById("divbox").style.display='block' document.onclick=function (){//页面点击事件(关闭"divbox") var event = window.event || event; var esrc = event.srcElement || event.target; if (esrc!=_this && esrc!=document.getElementById("divbox"))hidDiv() } }function hidDiv(){ document.getElementById("divbox").style.display='none' document.onclick=null}</script> 如何遍历出某json字段的长度 请教div渐入渐出效果 js写table不显示的问题 问几个javascript创建function的问题? 这段JS在火狐下报错求高手 PayPal接口和MSN接口问题 jqgrid查询编辑这些按钮显示不出来 JScript将字符串编译成URL的语句是什么? javscript 大量数据导出excel 网站测试,大家提提意见 请教无法显示查询结果的问题 怎样用JavaScript实现下拉菜单
document.onclick= document.getElementById("divId").style.display="none"[
document.onclick= document.getElementById("divId").style.display="none"
或者
document.onclick= document.getElementById("divId").style.visible="hiden"
但两种多少有点区别
<a hideFocus href="###" onclick="setDiv(this)">点击这里</a>
<div id="divbox" style="border:1px red dashed; display:none; width:301px; height:48px"></div>
<script language=JavaScript>
function setDiv(_this){
if (document.getElementById("divbox").style.display=='none')
showDiv(_this)
else
hidDiv()
}
function showDiv(_this){
document.getElementById("divbox").style.display='block'
document.onclick=function (){//页面点击事件(关闭"divbox")
var event = window.event || event;
var esrc = event.srcElement || event.target;
if (esrc!=_this && esrc!=document.getElementById("divbox"))hidDiv()
}
}
function hidDiv(){
document.getElementById("divbox").style.display='none'
document.onclick=null
}
</script>