2014-02-07 36 views
2

我在我的網站上爲我的滑塊使用此腳本。 我希望滑塊自動切換標籤。我有它的工作點擊事件,但我需要它在設定的時間間隔在標籤之間旋轉。 任何人都可以幫助我會很好嗎?在我的淡出腳本中包含自動切換

JS:

$(document).ready(function() { 
    //Default Action 
    $(".tab_content").hide(); //Hide all content 
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab 
    $(".tab_content:first").show(); //Show first tab content 
    //On Click Event 
    $("ul.tabs li").click(function() { 
      $("ul.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 rel attribute value to identify the active tab + content 
      $(activeTab).fadeIn(); //Fade in the active content 
      return false; 
    }); 
}); 

HTML:

<div style="float:left; width:290px; height:243px;"> 
    <ul class="tabs">{loop:navigation} 
     <li> <a style="color:#fff; text-decoration:none;" href="#tab{navigation:id}"> 
       {navigation:headline}<br /> 
       {navigation:text} 
      </a> 

     </li>{stop:navigation}</ul> 
</div> 
<div style="float:left; width:558px; height:243px;">{loop:specials} 
    <div id="tab{specials:id}" class="tab_content"> <a href="http://{specials:url}" title=""><img src="{page:path}{specials:pic}" width="{specials:width}" height="{specials:height}" alt="" /></a> 
    </div> 
    {stop:specials} 
</div> 
+1

我會明白..... 在一個嚴肅的筆記,你想達到什麼?在您向我們展示一些標記並更好地描述您的問題之前,這是毫無意義的。 – stackErr

+0

我在我的網站上爲我的滑塊http://team-whitex.de/2be/index.php使用此腳本。 通過點擊更改,但他也想自動切換選項卡。 – user3285248

+0

你能複製粘貼這個Javascript引用的HTML代碼嗎?最好不要發佈鏈接到網站 – stackErr

回答

0

從這裏(或一的quickfix)最簡單的方法是將觸發的間隔點擊功能:

setInterval(function(){ $("ul.tabs li").click(); }, 5000); // 5 seconds 

.click().trigger('click')相同,所以你可以使用你喜歡的更多。