欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)圖片簡單輪播功能示例

 更新時(shí)間:2018年08月13日 11:38:14   作者:筱葭  
這篇文章主要介紹了jQuery實(shí)現(xiàn)圖片簡單輪播功能,結(jié)合實(shí)例形式分析了jQuery基于定時(shí)器與事件響應(yīng)的頁面元素屬性動(dòng)態(tài)操作實(shí)現(xiàn)圖片輪播功能相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)圖片簡單輪播功能。分享給大家供大家參考,具體如下:

<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>www.dbjr.com.cn jQuery圖片輪播</title>
    <style type="text/css">
      #frame{
        width:700px;
        height:300px;
        position:relative;
      }
      #img2,#img3{
        display:none;
      }
      .box{
        position:absolute;
        width:50px;
        height:50px;
        line-height:50px;
        text-align:center;
        color:white;
        font-family:Microsoft-Yahei;
        background:grey;
      }
      #move1{
        bottom:0;
        right:100px;
      }
      #move2{
        bottom:0;
        right:50px;
      }
      #move3{
        bottom:0;
        right:0;
      }
    </style>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script>
      $(document).ready(function() {
        n = 1;
        interval = setInterval(
          function(){
            $("img").hide();
            $("#img"+n).show();
            $(".box").css("background","grey");
            $("#move"+n).css("background","red");
            n = n % 3 + 1;
          }
          ,
          2000
        );
        $(".box").bind("click",function() {
          clearInterval(interval);
          n = $(this).attr("id").slice(4);
          interval = setInterval(
            function(){
              $("img").hide();
              $("#img"+n).show();
              $(".box").css("background","grey");
              $("#move"+n).css("background","red");
              n = n % 3 + 1;
            }
            ,
            2000
          );
        });
      });
    </script>
  </head>
  <body>
    <div id="frame">
      <div id="photos">
        <img id="img1" src="images/background1.png">
        <img id="img2" src="images/background2.png">
        <img id="img3" src="images/background3.png">
      </div>
      <div class="box" id="move1">1</div>
      <div class="box" id="move2">2</div>
      <div class="box" id="move3">3</div>
    </div>
  </body>
</html>

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運(yùn)行工具http://tools.jb51.net/code/HtmlJsRun 測試運(yùn)行效果(記得替換上述圖片為網(wǎng)絡(luò)圖片)

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery圖片操作技巧大全》、《jQuery表格(table)操作技巧匯總》、《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)

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

相關(guān)文章

最新評(píng)論