2015-09-03 121 views
1

我所提到的這個插件是:http://plugins.jquery.com/project/fadeslideshow 這是我的腳本調用jumpTo()函數jumpTO功能無法正常工作

var slide; 
    jQuery(document).ready(function(){ 
     slide=jQuery('#slideshow').fadeSlideShow(); 

     $('ul.dropdown-menu li a').click(function(event) { 
     var newTopicContent = $(this).attr('id'); 
     slide.jumpTo(newTopicContent); 
     }); 
    }); 

當我運行這段代碼,控制檯提供了以下錯誤:

Uncaught TypeError: slide.jumpTo is not a function 

我在做什麼錯?請幫忙。

+0

當您使用第三方庫時,請確保您鏈接官方網站的問題,以便其他人能夠輕鬆幫助您。 –

+0

請參閱這個http://stackoverflow.com/questions/3023625/jquery-jump-to-id-no-animation這可能會幫助你。 –

+0

是[this](http://www.simplefadeslideshow.com/)的插件? –

回答

1

this怎麼樣?

功能跳滑梯

function jumpTo(slidenumber,restartAuto){ 
    $('#fssList li a').eq(parseInt(slidenumber) - 1).trigger('click'); 
    if(restartAuto == true){ 
     autoplay(); 
    } else { 
     stopAutoplay(); 
    } 
} 

這樣稱呼它jumpTo(1,true)true用於自動播放,false停止自動播放

如果您在頁面中有多個滑塊,請使用CSS選擇器觸發點擊。

+0

謝謝。其驚人的代碼和工作得很好。但是,如果我想要幻燈片的自動播放。我怎樣才能執行,而不使用autoplaypause按鈕。請幫忙。 @Cerlin老闆 –

+0

@ShwethaRS:我已經更新了代碼。希望這可以幫助你。 –