jquery实现点击链接弹出层效果:本例实现的主要原理:jquery操作dom元素。对层样式的设置。将display:设置为none;让层隐藏;
代码实例如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.jb51.net" />
<title>子选择器</title>
<style type="text/css">
#choice_list_district{
height:50px;
}
#tab td{
cursor:pointer;
}
#divobj{
position:absolute;
width:200px;
height:200px;
background:blue;
border:1px solid block;
display:none;
z-index:9999;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function (){
$("#choice_list_district a").click(function(e){
if($("#divobj").css("display")=="none"){
e.stopPropagation();
var offset=$(e.target).offset();
$("#divobj").css({top:offset.top+$(e.target).height()+"px",left:offset.left});
$("#divobj").show();
}
else{
$("#divobj").hide();
}
});
$(document).click(function(event){
$("#divobj").hide();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="choice_list_district"> <a href="#">出来层</a> </div>
<div id="divobj"></div>
</div>
</form>
</body>
</html>
以上就是基于jQuery实现点击弹出层实例代码_jquery的内容,更多相关内容请关注PHP中文网(www.php.cn)!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号