基于jquery鼠标点击其它地方隐藏层的实例代码
2011-01-23 00:00
811 查看
效果图:
下面的代码运行后,需要再刷新一下。
test
.div_d{ padding:10px; border:1px dotted red; position:absolute; display:none; cursor:pointer;}
$(function(){
$("input[id=search]").focus(function(even){
var pos=$(this).offset();
$(".div_d").css({left:pos.left,top:pos.top+20+"px",display:"block"});
});
document.onclick=function(e){
var e=e?e:window.event;
var tar = e.srcElement||e.target;
if(tar.id!="search"){
if($(tar).attr("class")=="div_d"){
$(".div_d").css("display","block")
}else{
$(".div_d").css("display","none");
}
}
}
})
脚本之家介绍信息
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
下面的代码运行后,需要再刷新一下。
test
.div_d{ padding:10px; border:1px dotted red; position:absolute; display:none; cursor:pointer;}
$(function(){
$("input[id=search]").focus(function(even){
var pos=$(this).offset();
$(".div_d").css({left:pos.left,top:pos.top+20+"px",display:"block"});
});
document.onclick=function(e){
var e=e?e:window.event;
var tar = e.srcElement||e.target;
if(tar.id!="search"){
if($(tar).attr("class")=="div_d"){
$(".div_d").css("display","block")
}else{
$(".div_d").css("display","none");
}
}
}
})
脚本之家介绍信息
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
相关文章推荐
- 基于jquery鼠标点击其它地方隐藏层的实例代码
- 关于鼠标点击其他地方隐藏层的实例(要引入jquery包哦)
- JQuery 鼠标点击其它地方隐藏层
- JQuery 鼠标点击其它地方隐藏层
- jQuery实现点击其它地方隐藏该div
- 基于JQuery实现鼠标点击文本框显示隐藏提示文本
- 由点击页面其它地方隐藏div所想到的jQuery的delegate
- 鼠标点击页面的其它地方div自动隐藏
- 由点击页面其它地方隐藏div所想到的jQuery的delegate
- 点击页面其它地方隐藏div所想到的jQuery的delegate
- jQuery实现鼠标点击div外的地方div隐藏消失的效果
- jQuery实现右侧功能栏、点击其它地方,右侧功能栏隐藏
- 点击页面其它地方隐藏div所想到的jQuery的delegate
- 基于jQuery实现点击弹出层实例代码
- jQuery实现点击除了特定div的页面其它地方,隐藏该div功能。
- jQuery实现鼠标点击div外的地方div隐藏
- 点击页面其它地方隐藏div所想到的jQuery的delegate
- 点击页面其它地方隐藏div所想到的jQuery的delegate
- 由点击页面其它地方隐藏div所想到的jQuery的delegate
- 基于JQuery实现鼠标点击文本框显示隐藏提示文本