2017-01-02 46 views
0

我在我的網站中使用bootstrap並解釋我的網站我想使用bootstrap tour。我已經在我的測試頁中實現了這一點,並且工作正常。但是在加載頁面時瀏覽開始,並且我想在點擊按鈕時開始瀏覽。我按照此article來實施我的引導遊覽。自助旅遊啓動按鈕

這是自舉遊試玩的一個javascript:

(function(){ 

    var tour = new Tour({ 
     storage : false 
    }); 

    tour.addSteps([ 
     { 
     element: ".tour-step.tour-step-one", 
     placement: "bottom", 
     title: "Welcome to our landing page!", 
     content: "This tour will guide you through some of the features we'd like to point out." 
     }, 
     { 
     element: ".tour-step.tour-step-two", 
     placement: "bottom", 
     title: "Main navigation", 
     content: "Here are the sections of this page, easily laid out." 
     }, 
     { 
     element: ".tour-step.tour-step-three", 
     placement: "top", 
     backdrop: true, 
     title: "Main section", 
     content: "This is a section that you can read. It has valuable information." 
     }, 

    ]); 

    // Initialize the tour 
    tour.init(); 

    // Start the tour 
    tour.start(); 

}()); 

,這是HTML部分:

<div class="content-section-a tour-step tour-step-one"> One <br> 

<div class="content-section-a tour-step tour-step-two"> Two <br> 

<div class="content-section-a tour-step tour-step-three"> Three <br> 

如何開始我遊通過點擊一個按鈕?

感謝

回答

0

當您單擊該按鈕,而不是在頁面加載只需撥打tour.start();。假設你的startbutton的編號爲start-tour。這個片段可以放置在(function() { ... })

$("#start-tour").click(function() { 
    tour.start(); 
}); 
+0

我有我的頁面添加此: ,這個按鈕:啓動 但不起作用 – Frankie

+0

如何關閉腳本在加載網頁的時間? – Frankie

+0

除了你已經做了什麼,你將不得不包括jQuery和刪除tour.init();從你的代碼。 –