2013-11-21 40 views
0

我通過我的網站瀏覽了一下。我希望用戶可以在遊覽結束後按鈕點擊手動啓動遊覽。如何手動啓動Bootstrap Tour?

按鈕:

<a href="#" id="tour"><i class=""></i> Start Tour</a> 

引導遊覽腳本。

<script type="text/javascript"> 
var tour = new Tour(); 
tour.addSteps([ 
{ 
    element: "#step1", 
    title: "Welcome.", 
    content: "Welcome to step one.", 
    placement: "top" 
} 
]); 
tour.addSteps([ 
{ 
    element: "#step2", 
    title: "Contact us.", 
    content: "If you have any questions, please contact us.", 
    placement: "left" 
} 

]); 
tour.start(); 
</script> 
+0

掛鉤鏈接到點擊後執行的代碼的功能。 – deceze

回答

3

這應該就像在JavaScript中爲按鈕添加點擊事件一樣簡單。

例如:

$('#tour').click(function(e){ 
    tour.start(); 

    // it's also good practice to preventDefault on the click event 
    // to avoid the click triggering whatever is within href: 
    e.preventDefault(); 
}); 
+0

OFC..nice,謝謝。 :) – strellson