2014-05-22 87 views
0

需要從滑塊中處於活動狀態的當前幻燈片獲取「數據編號」值。我想使用此值來顯示/隱藏頁面另一個div中的其他信息。或者,如果除了添加特定的「數據編號」值之外還有其他方法,請告訴我 - 我在文檔中沒有看到返回幻燈片編號的內容。responsiveslides.js - 獲取當前幻燈片

我知道我可以使用'後'回調然後做我想要的,但不知道我怎麼能得到這個值的第一個地方。

<div class="row"> 
    <div class="col-md-12"> 
     <ul class="rslides" id="slider1"> 
      <li data-number="1"> 
       <img src="/user-data/2/screenshots/demo21.jpg" alt=""> 
      </li> 
      <li data-number="2"> 
       <img src="/user-data/2/screenshots/demo22.jpg" alt=""> 
      </li> 
      <li data-number="3"> 
       <img src="/user-data/2/screenshots/demo23.jpg" alt=""> 
      </li> 
      <li data-number="4"> 
       <img src="/user-data/2/screenshots/demo24.jpg" alt=""> 
      </li> 
      <li data-number="5"> 
       <img src="/user-data/2/screenshots/demo25.jpg" alt=""> 
      </li> 
     </ul>    
    </div> 
</div> 

$("#slider1").responsiveSlides({ 
    auto: false,    // Boolean: Animate automatically, true or false 
    speed: 500,   // Integer: Speed of the transition, in milliseconds 
    timeout: 4000,   // Integer: Time between slide transitions, in milliseconds 
    pager: true,   // Boolean: Show pager, true or false 
    nav: true,    // Boolean: Show navigation, true or false 
    random: false,   // Boolean: Randomize the order of the slides, true or false 
    pause: false,   // Boolean: Pause on hover, true or false 
    pauseControls: true, // Boolean: Pause when hovering controls, true or false 
    prevText: "Previous", // String: Text for the "previous" button 
    nextText: "Next",  // String: Text for the "next" button 
    maxwidth: "",   // Integer: Max-width of the slideshow, in pixels 
    navContainer: "",  // Selector: Where controls should be appended to, default is after the 'ul' 
    manualControls: "",  // Selector: Declare custom pager navigation 
    namespace: "centered-btns", // String: Change the default namespace used 
    before: function(){}, // Function: Before callback 
    after: function(){}  // Function: After callback 
}); 

回答

2

無需數據屬性添加到列表中。您可以像這樣獲取當前幻燈片的索引:

$("#slider1").responsiveSlides({ 
    after: function(i){ 
     // i is equal to the index of the current active slide 
    // Your code here 
    } 
); 
+0

尼斯 - 謝謝! – user756659

0

您可以使用下面的代碼,以獲得您想要的號碼:

$('.rslides1_on').data('number'); 

或者

$('.rslides1_on').index() 
相關問題