【问题标题】:jquery tab auto slidejquery选项卡自动滑动
【发布时间】:2012-01-03 16:37:03
【问题描述】:

我正在使用以下代码在 jquery 中创建一个选项卡,当有人单击它时,它会打开该特定选项卡。那么是否可以对其进行修改,使其可以按指定间隔旋转选项卡。

    // Tabs
    // When page loads...
    $(".tab-content").hide(); //Hide all content
    $("ul.sidebar-tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab-content:first").show(); //Show first tab content

    // On Click Event
    $("ul.sidebar-tabs li").click(function() {

        $("ul.sidebar-tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab-content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

同样的html代码是,

<ul class="sidebar-tabs">
     <li><a href="#tab-1">Tab1</a></li>
     <li><a href="#tab-2">Tab2</a></li>
</ul><!-- //sidebar-tabs -->
 <div class="tab-container">
     <div id="tab-1" class="tab-content">
     <div>
     <div id="tab-2" class="tab-content">
     <div>
 </div>

【问题讨论】:

    标签: jquery tabs slide


    【解决方案1】:

    试试这个http://flowplayer.org/tools/tabs/index.html

    还有一个你可能会从http://www.smartnetzone.com/blog_demos/auto_rotating_tabs/开始的例子

    如果你想修改现有的,你可以这样做:

    jQuery("#tabs").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 3000);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      相关资源
      最近更新 更多