div.onblur的两个解决方法
来源:互联网 发布:windows.com 编辑:程序博客网 时间:2024/05/21 12:31
1.document.onclick
<div id="div1" onclick="test()">fff</div>
<div id="div2" style="display:none;width:200px;height:120px;"><input type="button" value="hide"/></div>
<script type="text/javascript">
function test () {
document.getElementById("div2").style.display="";
document.getElementById("div2").focus();
}
function hide (event) {
event=(event==null)?window.event:event;
var div2=document.getElementById("div2");
var div1=document.getElementById("div1");
var target_test=event.target?event.target:event.srcElement;
(target_test!=div2) && (target_test!=div1)?div2.style.display='none':null;
}
document.onclick=hide;
</script>
虽然没有用onblur,但是实现的效果是同样的
2.tabindex="0"
<div id="div3" onclick="test()">fff33</div>
<div id="div4" tabindex="0" onblur="hide()" style="display:none;width:200px;height:120px;"><input type="button" value="hide"/></div>
<script type="text/javascript">
function test () {
document.getElementById("div4").style.display="";
document.getElementById("div4").focus();
}
function hide () {
var div2=document.getElementById("div4");
div2.style.display='none';
}
</script>
这个实现的比较简单,但是不好的地方是div有一个虚线框,不晓得有没有办法去掉?
- div.onblur的两个解决方法
- div.onblur的两个解决方法
- div.onblur的两个解决方法、跳出详细框的控制
- div.onblur的两个解决方法、跳出详细框的控制
- div 没有onblur方法
- 两个div之间有空隙的起源和解决方法
- 两个相连的div
- 浏览器网页的onblur
- js 的 onblur 事件
- IE6 两个div有间隙的问题(IE 3px bug)解决方法
- 关于设置display:inline-block,使两个div产生空隙的解决方法
- HTML/CSS 有时两个div接合处会出现缝隙的解决方法
- 两个div之间的空隙
- 两个div并排的方法
- onblur的死锁和解决方案
- OnFocus与OnBlur的例子
- js的onblur和onfocus
- onblur和onfocus的区别
- linux下 tar解压 gz解压 bz2等各种解压文件使用方法
- 找出数组中两个只出现一次的数字
- JS获取Select标签的选取值和文本
- DRBD 安装配置
- 用python做安装包
- div.onblur的两个解决方法
- 常用的正则表达式
- apache status 报告分析
- FireFox 中form.submit() 不执行 解决方案
- ubuntu中vim和gedit中文乱码
- Ant引入第三方jar遇到的问题
- webbrowers用法集
- UIUC同学Jia-Bin Huang收集的计算机视觉代码合集(ZZ)
- ajax技术示例