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