我浏览了我的网站。我希望用户在结束游览后可以在单击按钮时手动开始游览。

按键:

<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中的按钮上添加click事件一样简单。

例如:

$('#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();
});

关于javascript - 如何手动启动Bootstrap Tour?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20125331/

10-11 12:32