非常简单的jQuery DIV遮罩层,点击查看DEMO
代码如下所示:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>jQuery 的DIV遮罩层示例</title>
<script type=’text/javascript’ src=’http://code.jquery.com/jquery-latest.js’></script>
<style>
.targetDiv{display:none;}
.txt{ border:solid 20px #000000; width:400px; height:400px; margin:100px auto auto 400px; color:#fff;}
.cbtn{margin-top:-20px; text-align:right; margin-right:-20px;}
.txt a{text-decoration:none; color:#fff;}
</style>
<script>
$(document).ready(function(){
$(‘.main a’).click(function(){
$(this).parent().find(‘.targetDiv’).css({ “position”: “absolute”, “text-align”: “center”, “top”: “0px”, “left”: “0px”,”background”: “#555″, “display”: “block”,’width’:’100%’,'height’:$(document).height(), “filter”: “Alpha(opacity=80)”,’opacity’:’0.8′});
});
$(‘.targetDiv,.cbtn a’).click(function(){
$(this).parent().find(‘.targetDiv’).css(‘display’,'none’);
});
});
</script>
</head>
<body>
<div>
<a href=”#”>点我显示jQuery的DIV遮罩层 http://jerryji.cn</a>
<div>
<div>
<div><a href=”#”>关闭 Close</a></div>
<p>这里是正文内容 <a href=”http://jerryji.cn”>http://jerryji.cn</a></p>
</div>
</div>
</div>
<p>By Jerry Jee</p>
<p><a href=”http://jerryji.cn”>http://jerryji.cn</a></p>
</body>
</html>
Popularity: 12%