醉丶春风的Blog

千里之行, 始于足下



基于jQuery实现点击弹出层实例代码


<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.xstnet.com"/>
 
<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="js/jQuery/jquery-1.8.1.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>



作者: 徐善通
地址: https://www.xstnet.com/article-58.html
声明: 除非本文有注明出处,否则转载请注明本文地址


我有话说



最新回复


正在加载中....

Copyrights © 2016-2019 醉丶春风 , All rights reserved. 皖ICP备15015582号-1