zoukankan      html  css  js  c++  java
  • 手动轮播 自动轮播精简版本

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    <body>
    <script>
    $(function(){
    //开场显示
    $('.pica').eq(0).show();
    $('.yema li').eq(0).addClass('cur');

    //定义指针索引
    var idx = $('.yema li.cur').index();

    //显示轮播图和黄色导航圈
    function showAll(){
    $('.pica').hide();
    $('.pica').eq(idx).show();
    $('.yema li').removeClass('cur');
    $('.yema li').eq(idx).addClass('cur');
    }
    //左边按钮
    $('.pre').click(function(){
    idx = (idx > 0) ? idx - 1 : 4;
    showAll();
    });

    //右边按钮
    $('.nxt').click(function(){
    idx = (idx < 4) ? idx + 1 : 0;
    showAll();
    });

    //黄色导航
    $('.yema li').mouseover(function(){
    idx = $(this).index();
    showAll();
    });

    //自动轮播
    setInterval(function(){
    idx = (idx < 4) ? idx + 1 : 0;
    showAll();
    }, 2500);

    });

    </script>
    </body>
    </html>

  • 相关阅读:
    IO流
    泛型类
    自动打包&解包:auto-boxing&unboxing
    Map接口
    如何选择数据结构
    Compareable接口
    List常用算法
    equals和==
    List接口
    set接口
  • 原文地址:https://www.cnblogs.com/TTTK/p/6253046.html
Copyright © 2011-2022 走看看