這篇文章主要介紹了jQuery如何實(shí)現(xiàn)頁面遮罩層功能,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
創(chuàng)新互聯(lián)是專業(yè)的威海網(wǎng)站建設(shè)公司,威海接單;提供成都做網(wǎng)站、網(wǎng)站建設(shè)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行威海網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(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>www.jb51.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*/ /*只是用來控制位置的*/ 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> <!--頁面上原先有的內(nèi)容(用來執(zhí)行點(diǎn)擊)--> <section class="fh-link-bar" id="sexlog"> <span>性別</span> <span class="fh-data" id="personsex">男</span> </section> <!--頁面上原先沒有的內(nèi)容(用來執(zhí)行點(diǎn)擊后生成的提示框)--> <div class="personsex" > <p>保密</p> <p>男</p> <p>女</p> </div> </body> <script src="jquery-1.7.2.min.js"></script> <script type="text/javascript"> //添加頁面遮罩 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%"); }/*刪除頁面遮罩*/ function removeShade() { $(".loading-shade").remove(); } /*頁面遮罩點(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)用的頁面添加的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)用的頁面添加的js(這里是點(diǎn)擊遮罩層實(shí)現(xiàn)遮罩層(即:.loading-shade)頁面關(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)行效果:
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“jQuery如何實(shí)現(xiàn)頁面遮罩層功能”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
本文名稱:jQuery如何實(shí)現(xiàn)頁面遮罩層功能
路徑分享:http://aaarwkj.com/article46/iigphg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、品牌網(wǎng)站制作、域名注冊(cè)、網(wǎng)站營(yíng)銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)