最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實現(xiàn)查看圖片功能

 更新時間:2020年12月01日 09:22:56   作者:從入門to入萬  
這篇文章主要為大家詳細(xì)介紹了jQuery實現(xiàn)查看圖片,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了jQuery實現(xiàn)查看圖片的具體代碼,供大家參考,具體內(nèi)容如下

HTML

<!-- 放縮略圖的div -->
  <div class="sl">
    <img src="images/1.jpg" />
    <img src="images/2.jpg" />
    <img src="images/3.jpg" />
  </div>
  <!-- 實現(xiàn)關(guān)燈的div -->
  <div class="gd"></div>
  <div class="yt">
    <!-- 左翻按鈕 -->
    <div class="left">
      <img src="images/left.png" alt="" width="100">
    </div>
    <div class="tp">
      <!-- 展示原圖 -->
      <img src="images/1.jpg" class="show" />
      <!--放開始和結(jié)束圖片的盒子 -->
       <div class="ss" style="display: none;">
        <img src="images/start.png" alt="" width="50" class="start">
      </div>
    </div>
    <!-- 右翻按鈕 -->
    <div class="right">
      <img src="images/right.png" alt="" width="100">
    </div>
</div>

CSS

 html,body{
    padding: 0;
    margin: 0;
  }
  .sl img {
    width: 300px;
  }

  .gd {
    background-color: rgba(0, 0, 0, 0.7);
    position: absolute;
    z-index: 900;
    display: none;
    top: 0;
    left: 0;
  }

  .sl {
    position: absolute;
    z-index: 888;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sl>img {
    width: 25%;
  }

  .yt {
    z-index: 990;
    position: absolute;
    display: none;
    left: 500px;
    top: 200px;
  }

  .tp {
    margin: 0 20px;
  }

  .yt>div {
    display: inline-block;
  }

  .left,
  .right {
    position: relative;
    top: -110px;
    cursor: pointer;
  }

  .ss {
    position: relative;
    width: 50px;
    height: 50px;
    left: 270px;
  }

  .start {
    z-index: 990;
    position: absolute;
  }

JS

var max = $(".sl img").length;
$(function (e) {
  var width = $(window).width();
  var height = $(window).height();
  $(".gd").css({
    "height": height,
    "width": width
  });

  //左翻按鈕動畫
  $(".left").hover(
    function () {
      $(this).animate({
        "left": "-10"
      });
    },
    function () {
      $(this).animate({
        "left": "0"
      });
    }
  );
  //右翻按鈕動畫
  $(".right").hover(
    function () {
      $(this).animate({
        "right": "-10"
      });
    },
    function () {
      $(this).animate({
        "right": "0"
      });
    }
  );

  //被點擊的縮略圖
  $(".sl>img").click(function (e) {
    $(".gd").show(500);
    $(".yt").fadeIn(800);
    var index = $(this).index(); //當(dāng)前被點擊圖片的索引
    $(".tp>img").attr("src", "images/" + (index + 1) + ".jpg");
    //左翻
    $(".left").click(function (e) {
      if (index - 1 < 0) {
        index = max - 1;
      } else {
        index = index - 1;
      }
      $(".tp>img").attr("src", "images/" + (index + 1) + ".jpg");
    });
    //右翻
    $(".right").click(function (e) {
      if (index == max - 1) {
        index = 0;
      } else {
        index = index + 1;
      }
      $(".tp>img").attr("src", "images/" + (index + 1) + ".jpg");
    });

    //隱藏和顯示播放按鈕
    $(".tp").hover(
      function () {
        $(".ss").fadeIn(500);
        $(this).animate({
          "opacity": "0.7"
        }, 700);
      },
      function () {
        $(".ss").fadeOut(500);
        $(this).animate({
          "opacity": "1"
        }, 700);
      }
    );
 //點擊開始播放 再次點擊結(jié)束播放
    let flag = true;
    $(".start").click(function () {
      if (flag == true) {
        time = setInterval(function () {
          if (index == max - 1) {
            index = 0;
          } else {
            index = index + 1;
          }
          $(".tp>img").attr("src", "images/" + (index + 1) + ".jpg");
        }, 2000);
        flag = false;
        $(".start").attr("src", "images/stop.png");
      } else {
        clearInterval(time);
        flag = true;
        $(".start").attr("src", "images/start.png");
      }
    });
    let h = $(".tp>img").height();
    $(".ss").css({
      "top": -h / 2 - 25
    });
    //隱藏關(guān)燈效果
    $(".gd").click(function () {
      $(".gd").hide(800);
      $(".yt").fadeOut(500);
    });
  });
});

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用jQuery實現(xiàn)的擲色子游戲動畫效果

    使用jQuery實現(xiàn)的擲色子游戲動畫效果

    大家一定都玩過擲色子的游戲,今天我給大家分享的是如何使用jQuery來實現(xiàn)擲色子的動畫效果,通過jQuery的animate()自定義動畫函數(shù)并結(jié)合CSS背景圖片切換實現(xiàn)的動畫效果
    2014-03-03
  • jquery之empty()與remove()區(qū)別說明

    jquery之empty()與remove()區(qū)別說明

    要用到移除指定元素的時候,發(fā)現(xiàn)empty()與remove([expr])都可以用來實現(xiàn)。可仔細(xì)觀察效果的話就可以發(fā)現(xiàn)。
    2010-09-09
  • jQuery中parents()方法用法實例

    jQuery中parents()方法用法實例

    這篇文章主要介紹了jQuery中parents()方法用法,實例分析了parents()方法的功能、定義及取得一個包含著所有匹配元素的父輩元素的元素集合使用技巧,需要的朋友可以參考下
    2015-01-01
  • Jqgrid之強(qiáng)大的表格插件應(yīng)用

    Jqgrid之強(qiáng)大的表格插件應(yīng)用

    jqGrid是一款基于jQuery的功能強(qiáng)大的表格插件,使用jqGrid可以輕松實現(xiàn)前端頁面與后臺數(shù)據(jù)進(jìn)行ajax異步通信,jqGrid運(yùn)行速度相當(dāng)快,可以很好的應(yīng)用在一些后臺管理系統(tǒng)來管理大量數(shù)據(jù)的場合
    2015-12-12
  • jquery實現(xiàn)簡易的移動端驗證表單

    jquery實現(xiàn)簡易的移動端驗證表單

    本文給大家匯總介紹了幾個常用的jquery實現(xiàn)簡易的移動端驗證表單,非常的實用,有需要的小伙伴可以進(jìn)來參考下。
    2015-11-11
  • jQuery實現(xiàn)文章收起與展開功能

    jQuery實現(xiàn)文章收起與展開功能

    這篇文章主要為大家詳細(xì)介紹了jQuery實現(xiàn)文章收起與展開功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • jquery 設(shè)置元素相對于另一個元素的top值(實例代碼)

    jquery 設(shè)置元素相對于另一個元素的top值(實例代碼)

    在jquery中offset().top是相對于body來說的,另外在設(shè)置top值的時候要找到與該元素最近的有相對值的元素
    2013-11-11
  • jquery.simple.tree插件 更簡單,兼容性更好的無限樹插件

    jquery.simple.tree插件 更簡單,兼容性更好的無限樹插件

    在這里介紹一款小巧,功能強(qiáng)大,能拖拽,支持異步,且兼容性更高的jquery Tree插件
    2010-09-09
  • jquery獲取顏色在ie和ff下的區(qū)別示例介紹

    jquery獲取顏色在ie和ff下的區(qū)別示例介紹

    在使用$(#id).attr(color) 獲取顏色的時候,ie和ff是不同的,下面有個示例,大家可以參考下
    2014-03-03
  • 常見的jQuery選擇器匯總

    常見的jQuery選擇器匯總

    本文匯總介紹了常見的jQuery選擇器知識,包含基本元素選擇器、分層選擇器、基本條件選擇器、內(nèi)容條件選擇器、可見性條件選擇器、屬性選擇器、子元素選擇器、表單元素選擇器、表單屬性選擇器。十分的詳盡,有需要的小伙伴參考下吧
    2014-11-11

最新評論

桐梓县| 武冈市| 青浦区| 兴和县| 澄迈县| 望奎县| 南城县| 邢台县| 绥化市| 扶绥县| 渑池县| 柳河县| 织金县| 祁东县| 襄汾县| 洪雅县| 铁力市| 博白县| 开化县| 姚安县| 昌乐县| 塘沽区| 肥城市| 宝丰县| 赤壁市| 浦县| 昌都县| 蛟河市| 新津县| 南岸区| 大邑县| 青川县| 郸城县| 甘肃省| 诸城市| 新河县| 兴国县| 莎车县| 兴山县| 沙坪坝区| 株洲市|