jQuery如何实现页面遮罩层功能

这篇文章主要介绍了jQuery如何实现页面遮罩层功能,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

创新互联是专业的威海网站建设公司,威海接单;提供成都做网站、网站建设、外贸营销网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行威海网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

具体如下:



  
    
    
    
    
    
    www.jb51.net 遮罩层
    
      .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;  /*层级关系为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;      /*层级关系为102*/
      }
      .loading-shade{
        height: 100%;
        width: 100%;
        top: 0;
        left: 0;
      }
    
  
  
    
    
         性别
        男
    
    
    
      

保密

      

      

    
             //添加页面遮罩     function addShade() {       var htmlHeight = document.body.scrollHeight || document.documentElement.scrollHeight;       $("body").append('
');       //$(".loading-shade").css("height",htmlHeight+"px");       $(".loading-shade").css("100%");     }/*删除页面遮罩*/     function removeShade() {       $(".loading-shade").remove();     }     /*页面遮罩点击关闭弹出层      * dom=>#id      * type => hide || remove      * */     function closeDiv(dom, type) {       $(".loading-shade").click(function() {         type == "hide" ? $(dom).hide() : $(dom).remove();         $(".loading-shade").remove();       })     }     //需要调用的页面添加的js(这里是点击上边的div(即:.personsex p元素)的时候实现遮罩层消失。) //   $('#sexlog,#personsex').unbind("click").bind("click",function(){ //      addShade(); //      $('.personsex').show(); //   }); // //   $('.personsex p').bind('click',function(){ //      $('.loading-shade').remove(); //      $('.personsex').hide(); //   });     //======================================================================================     //需要调用的页面添加的js(这里是点击遮罩层实现遮罩层(即:.loading-shade)页面关闭)      $('#sexlog,#personsex').unbind("click").bind("click",function(){        addShade();        $('.personsex').show();        del();     });     function del(){        $('.loading-shade').bind('click',function(){          $('.loading-shade').remove();          $('.personsex').hide();       });     }   

运行效果:

jQuery如何实现页面遮罩层功能

感谢你能够认真阅读完这篇文章,希望小编分享的“jQuery如何实现页面遮罩层功能”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


文章标题:jQuery如何实现页面遮罩层功能
当前链接:http://scyanting.com/article/iigphg.html

其他资讯