JavaScript实现的弹出遮罩层特效经典示例【基于jQuery】-创新互联

本文实例讲述了JavaScript实现的弹出遮罩层特效。分享给大家供大家参考,具体如下:

丹徒ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

这篇给大家分享一个简单的遮罩层特效,先上效果图。

JavaScript实现的弹出遮罩层特效经典示例【基于jQuery】

代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>查看,修改,删除</title>
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <style>
    table{
      width:500px;
      border:1px solid blue;
      border-collapse: collapse;
    }
    table th{
      border:1px solid blue;
      height:30px;
    }
    table td{
      border:1px solid blue;
      text-align:center;
      height:30px;
    }
    table td a {
      color:red;
    }
    div.proDiv{
      width:500px;
      position: absolute;
      left:50%;
      margin-left:-250px;
      padding:10px;
      border:1px solid red;
      top:100px;
      background: #fff;
      display: none;
      z-index: 3
    }
    div.proDiv p{
      border-bottom:1px solid red;
    }
    div.proDiv a.close{
      color:red;
    }
  </style>
</head>
<body>
  <table>
    <tr>
      <th>姓名</th>
      <th>年龄</th>
      <th>工作</th>
      <th>工资</th>
      <th>操作</th>
    </tr>
    <tr>
      <td>张三</td>
      <td>22</td>
      <td>项目经理</td>
      <td>12000</td>
      <td>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="view">查看</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >修改</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="del">删除</a>
      </td>
    </tr>
    <tr>
      <td>李四</td>
      <td>24</td>
      <td>前端工程师</td>
      <td>10000</td>
      <td>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="view">查看</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >修改</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="del">删除</a>
      </td>
    </tr>
    <tr>
      <td>王五</td>
      <td>21</td>
      <td>java工程师</td>
      <td>12000</td>
      <td>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="view">查看</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >修改</a>
        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="del">删除</a>
      </td>
    </tr>
  </table>
  <div class="proDiv">
    <p><strong>姓名:</strong><span></span></p>
    <p><strong>年龄:</strong><span></span></p>
    <p><strong>工作:</strong><span></span></p>
    <p><strong>工资:</strong><span></span></p>
    <a class="close" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >关闭</a>
  </div>
</body>
<script>
  //查看操作
  $('a.view').click(function(){
    //获取文档的宽和高
    var maskWidth = $(document).width();
    var maskHeight = $(document).height();
    //遮罩层初始化
    $('<div class="mask"></div>').appendTo($('body'));
    $('div.mask').css({
      'position':'absolute',
      'top':0,
      'left':0,
      'background':'black',
      'opacity':0.5,
      'width':maskWidth,
      'height':maskHeight,
      'z-index':2
    });
    var data = [];//保存数据的数组
    //将一行的数据添加到数据中
    $(this).parent().siblings().each(function(){
      data.push($(this).text())
    });
    //将内容显示到弹出层中
    $('div.proDiv').children().each(function(i){
      $(this).children('span').text(data[i]);
    });
    $('div.proDiv').show();//显示弹出层
    //关闭操作
    $('a.close').click(function(){
      $(this).parent().hide();
      $('div.mask').remove();
    });
  });
  //删除操作
  $('a.del').click(function(){
    $(this).parents('tr').remove();
  });
</script>
</html>

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

新闻名称:JavaScript实现的弹出遮罩层特效经典示例【基于jQuery】-创新互联
分享网址:https://www.cdcxhl.com/article48/dohdep.html

成都网站建设公司_创新互联,为您提供网站内链标签优化用户体验定制网站外贸建站网站收录

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

h5响应式网站建设