jQuery實(shí)現(xiàn)的頁(yè)面遮罩層功能示例【測(cè)試可用】
本文實(shí)例講述了jQuery實(shí)現(xiàn)的頁(yè)面遮罩層功能。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="description" content="aportpower"/>
<title>m.fzitv.net 遮罩層</title>
<style type="text/css">
.fh-link-bar {
border-top: none;
}
.fh-link-bar {
background-color: #fff;
border: 1px solid #eaeaea;
border-left: none;
border-right: none;
padding: 10px;
height: 50px;
line-height: 30px;
font-size: 14px;
}
#personsex{
float: right;
}
.personsex {
background: magenta;
width: 150px;
height: 180px;
line-height: 40px;
text-align: center;
border-radius: 2px;
z-index: 104; /*層級(jí)關(guān)系為104*/
/*只是用來(lái)控制位置的*/
position: absolute;
margin: 100px auto;
font-size: 20px;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
/*一定要記得添加樣式(必須)*/
.loading-shade {
position: fixed; /*窗口定位*/
background: rgba(0,0,0,.5); /*遮罩層的顏色*/
z-index: 102; /*層級(jí)關(guān)系為102*/
}
.loading-shade{
height: 100%;
width: 100%;
top: 0;
left: 0;
}
</style>
</head>
<body>
<!--頁(yè)面上原先有的內(nèi)容(用來(lái)執(zhí)行點(diǎn)擊)-->
<section class="fh-link-bar" id="sexlog">
<span>性別</span>
<span class="fh-data" id="personsex">男</span>
</section>
<!--頁(yè)面上原先沒(méi)有的內(nèi)容(用來(lái)執(zhí)行點(diǎn)擊后生成的提示框)-->
<div class="personsex" style="display: none;">
<p>保密</p>
<p>男</p>
<p>女</p>
</div>
</body>
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
//添加頁(yè)面遮罩
function addShade() {
var htmlHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
$("body").append('<div class="loading-shade"></div>');
//$(".loading-shade").css("height",htmlHeight+"px");
$(".loading-shade").css("100%");
}/*刪除頁(yè)面遮罩*/
function removeShade() {
$(".loading-shade").remove();
}
/*頁(yè)面遮罩點(diǎn)擊關(guān)閉彈出層
* dom=>#id
* type => hide || remove
* */
function closeDiv(dom, type) {
$(".loading-shade").click(function() {
type == "hide" ? $(dom).hide() : $(dom).remove();
$(".loading-shade").remove();
})
}
//需要調(diào)用的頁(yè)面添加的js(這里是點(diǎn)擊上邊的div(即:.personsex p元素)的時(shí)候?qū)崿F(xiàn)遮罩層消失。)
// $('#sexlog,#personsex').unbind("click").bind("click",function(){
// addShade();
// $('.personsex').show();
// });
//
// $('.personsex p').bind('click',function(){
// $('.loading-shade').remove();
// $('.personsex').hide();
// });
//======================================================================================
//需要調(diào)用的頁(yè)面添加的js(這里是點(diǎn)擊遮罩層實(shí)現(xiàn)遮罩層(即:.loading-shade)頁(yè)面關(guān)閉)
$('#sexlog,#personsex').unbind("click").bind("click",function(){
addShade();
$('.personsex').show();
del();
});
function del(){
$('.loading-shade').bind('click',function(){
$('.loading-shade').remove();
$('.personsex').hide();
});
}
</script>
</html>
運(yùn)行效果:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery窗口操作技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jquery中Ajax用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- JQuery 遮罩層實(shí)現(xiàn)(mask)實(shí)現(xiàn)代碼
- jquery彈出關(guān)閉遮罩層實(shí)例
- jQuery操作dom實(shí)現(xiàn)彈出頁(yè)面遮罩層(web端和移動(dòng)端阻止遮罩層的滑動(dòng))
- jQuery+AJAX實(shí)現(xiàn)遮罩層登錄驗(yàn)證界面(附源碼)
- jQuery彈出遮罩層效果完整示例
- jQuery阻止移動(dòng)端遮罩層后頁(yè)面滾動(dòng)
- Jquery實(shí)現(xiàn)遮罩層的方法
- jQuery點(diǎn)擊按鈕彈出遮罩層且內(nèi)容居中特效
- jQuery遮罩層實(shí)現(xiàn)方法實(shí)例詳解(附遮罩層插件)
- jquery實(shí)現(xiàn)點(diǎn)擊其他區(qū)域時(shí)隱藏下拉div和遮罩層的方法
- 輕量級(jí)網(wǎng)頁(yè)遮罩層jQuery插件用法實(shí)例
- jQuery實(shí)現(xiàn)彈出帶遮罩層的居中浮動(dòng)窗口效果
相關(guān)文章
js/jq仿window文件夾移動(dòng)/剪切/復(fù)制等操作代碼
本篇文章主要介紹了js/jq仿window文件夾移動(dòng)/剪切/復(fù)制等操作代碼,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。2017-03-03
jquery實(shí)現(xiàn)類似淘寶星星評(píng)分功能實(shí)例
這篇文章主要介紹了jquery實(shí)現(xiàn)類似淘寶星星評(píng)分功能,詳細(xì)介紹了相應(yīng)jQuery事件的用法實(shí)例,需要的朋友可以參考下2014-09-09
jquery 學(xué)習(xí)之二 屬性相關(guān)
jquery 學(xué)習(xí)之二 屬性相關(guān)資料,學(xué)習(xí)jquery的朋友可以參考下。2010-11-11
webpack中引用jquery的簡(jiǎn)單實(shí)現(xiàn)
下面小編就為大家?guī)?lái)一篇webpack中引用jquery的簡(jiǎn)單實(shí)現(xiàn)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06
jquery實(shí)現(xiàn)漫天雪花飛舞的圣誕祝福雪花效果代碼分享
這篇文章主要介紹了jquery實(shí)現(xiàn)漫天雪花飛舞的圣誕祝福雪花效果,很浪漫,感興趣的小伙伴們可以參考一下2015-08-08
JQuery實(shí)現(xiàn)簡(jiǎn)單時(shí)尚快捷的氣泡提示插件
在程序提交后,為了提高用戶體驗(yàn)我們需要驗(yàn)證并提示出錯(cuò)的位置,利用JQuery我們可以輕松實(shí)現(xiàn)氣泡提示,需要的朋友可以了解下2012-12-12
jQuery簡(jiǎn)單實(shí)現(xiàn)MD5加密的方法
這篇文章主要介紹了jQuery簡(jiǎn)單實(shí)現(xiàn)MD5加密的方法,基于jquery.md5.js插件實(shí)現(xiàn)md5加密功能,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2017-03-03
ASP.NET jQuery 實(shí)例9 通過(guò)控件hyperlink實(shí)現(xiàn)返回頂部效果
ASP.NET jQuery 實(shí)例9 通過(guò)控件hyperlink實(shí)現(xiàn)返回頂部效果的實(shí)現(xiàn)代碼,需要的朋友可以參考下2012-02-02

