如何手动启动引导程序

How to manually start Bootstrap Tour?

本文关键字:引导程序 启动 何手动      更新时间:2023-09-26

我浏览了我的网站。我希望用户可以在结束巡演后点击按钮手动启动巡演。

按钮:

<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>

这应该像在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(); 
});