亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript實現(xiàn)的彈出遮罩層特效經(jīng)典示例【基于jQuery】

 更新時間:2019年07月10日 11:29:31   作者:webbc  
這篇文章主要介紹了JavaScript實現(xiàn)的彈出遮罩層特效,結(jié)合實例形式分析了基于jQuery實現(xiàn)的頁面元素與屬性動態(tài)操作相關(guān)使用技巧,需要的朋友可以參考下

本文實例講述了JavaScript實現(xiàn)的彈出遮罩層特效。分享給大家供大家參考,具體如下:

這篇給大家分享一個簡單的遮罩層特效,先上效果圖。

代碼:

<!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>項目經(jīng)理</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" >關(guān)閉</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 = [];//保存數(shù)據(jù)的數(shù)組
    //將一行的數(shù)據(jù)添加到數(shù)據(jù)中
    $(this).parent().siblings().each(function(){
      data.push($(this).text())
    });
    //將內(nèi)容顯示到彈出層中
    $('div.proDiv').children().each(function(i){
      $(this).children('span').text(data[i]);
    });
    $('div.proDiv').show();//顯示彈出層
    //關(guān)閉操作
    $('a.close').click(function(){
      $(this).parent().hide();
      $('div.mask').remove();
    });
  });
  //刪除操作
  $('a.del').click(function(){
    $(this).parents('tr').remove();
  });
</script>
</html>

頁面中有一個表格,一個隱藏的彈出層,當點擊查看按鈕,首先創(chuàng)建一個遮罩層,然后獲取這一行中的數(shù)據(jù),并把數(shù)據(jù)顯示到彈出層中,最后把彈出層隱藏,點擊關(guān)閉按鈕關(guān)閉彈出層并關(guān)閉遮罩層。點擊刪除按鈕把這個tr刪除即可。

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運行工具http://tools.jb51.net/code/HtmlJsRun測試上述代碼運行效果。

更多關(guān)于jQuery相關(guān)內(nèi)容可查看本站專題:《jQuery頁面元素操作技巧匯總》、《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery擴展技巧總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計有所幫助。

相關(guān)文章

  • 推薦40個非常優(yōu)秀的jQuery插件和教程【系列三】

    推薦40個非常優(yōu)秀的jQuery插件和教程【系列三】

    jQuery 在如今的 Web 開發(fā)項目中扮演著重要角色,jQuery 以其插件眾多、獨特、輕量以及支持大規(guī)模的網(wǎng)站開發(fā)聞名。本文大家分享40個實用的 jQuery 插件,可以根據(jù)您的項目需要來選擇使用
    2011-11-11
  • jQuery實現(xiàn)DIV層收縮展開的方法

    jQuery實現(xiàn)DIV層收縮展開的方法

    這篇文章主要介紹了jQuery實現(xiàn)DIV層收縮展開的方法,實例分析了jQuery中toggle與animate等方法的使用技巧,需要的朋友可以參考下
    2015-02-02
  • 基于jquery實現(xiàn)頁面滾動時頂部導航顯示隱藏

    基于jquery實現(xiàn)頁面滾動時頂部導航顯示隱藏

    這篇文章主要介紹了基于jquery實現(xiàn)頁面滾動時頂部導航顯示隱藏效果,當頁面向下滾動的時候,導航菜單動態(tài)隱藏,頁面滾動到頂部時,導航菜單動態(tài)顯示,淘寶也采用過此效果,感興趣的小伙伴們可以參考一下
    2015-11-11
  • jquery驗證表單中的單選與多選實例

    jquery驗證表單中的單選與多選實例

    這里所說的,用jquery去驗證某一組多選至少要有一個選中,某一組單選至少有一個選中,,大家都知道單一的一個用js比較好驗證,但是想要用jquery的驗證并且用到j(luò)query驗證的提示信息,那么這就不好辦了
    2013-08-08
  • jQuery實現(xiàn)簡單評論區(qū)

    jQuery實現(xiàn)簡單評論區(qū)

    這篇文章主要為大家詳細介紹了jQuery實現(xiàn)簡單評論區(qū),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-03-03
  • 如何讓你的Lightbox支持滾輪縮放及Base64圖片

    如何讓你的Lightbox支持滾輪縮放及Base64圖片

    本文主要是記錄了1、修改Lightbox源碼使支持滾輪縮放;2、修改Lightbox源碼使圖片的源可支持base64格式;3、如何將Lightbox應(yīng)用到已有的文章。非常的簡單實用,正在使用lightbox的小伙伴可以重點看下,應(yīng)用到自己項目中,立刻高大上了
    2014-12-12
  • Jquery+bootstrap實現(xiàn)表格行置頂置底上移下移操作詳解

    Jquery+bootstrap實現(xiàn)表格行置頂置底上移下移操作詳解

    這篇文章主要為大家詳細介紹了Jquery+bootstrap實現(xiàn)表格行置頂置底上移下移操作,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Jquery Easyui日歷組件Calender使用詳解(23)

    Jquery Easyui日歷組件Calender使用詳解(23)

    這篇文章主要為大家詳細介紹了Jquery Easyui日歷組件Calender的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • JQuery為頁面Dom元素綁定事件及解除綁定方法

    JQuery為頁面Dom元素綁定事件及解除綁定方法

    這篇文章主要介紹了JQuery為頁面Dom元素綁定事件及解除綁定方法,需要的朋友可以參考下
    2014-04-04
  • jQuery瀑布流插件Wookmark使用實例

    jQuery瀑布流插件Wookmark使用實例

    Wookmark jQuery插件大致使用position:absolute來重構(gòu)內(nèi)容實現(xiàn)瀑布流布局,需要的朋友可以參考下
    2014-04-04

最新評論