How to manually start Bootstrap Tour?

别来无恙 提交于 2020-01-06 15:15:16

问题


I made a tour through my website. I want that users can start the tour manually on button click after they end the tour.

Button:

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

Bootstrap tour script.

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

回答1:


This should be as simple as adding a click event to the button in your JavaScript.

For example:

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


来源:https://stackoverflow.com/questions/20125331/how-to-manually-start-bootstrap-tour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!