本文介绍了如何手动启动 Bootstrap Tour?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I made a tour through my website. I want that users can start the tour manually on button click after they end the 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>

推荐答案

这应该就像在 JavaScript 中向按钮添加点击事件一样简单.

This should be as simple as adding a click event to the button in your 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(); 
});

这篇关于如何手动启动 Bootstrap Tour?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 06:54