以下是我的引用代码:
我正在为我的应用程序使用 Bootstrap 游览。
要求:
- 当我点击“下一步”时,我处于第一步,然后它正在检查“#id2”的值。 如果 id2 值不为空,则应跳过该步骤并直接进入第三步。
为此,我正在尝试tour.goTo(3)。 但这是行不通的。 有什么帮助吗?
tour.addSteps([
{
element:" #id1",
title: "1",
content: "1st Content.",
placement: "top",
onShow: function () {
console.log('This is Onshow Function');
},
onNext: function () {
client_text = $('#id2').text();
if(client_text != ''){
console.log('----------client code present----------');
tour.goTo(3)
//tour.next();
//tour.hideStep(2)
return false
}
else{
console.log('-------client code not present--------');
}
},
onHidden:function () {
tour.hideStep(2)
}
},
{
element:" #id2",
title: "2",
content: "2nd Content",
placement: "top",
onShow: function () {
console.log('second step');
}
},
{
element:" #id3",
title: "3",
content: "3rd Content",
placement: "top",
onShow: function () {
console.log('third step');
}
}
]);
最佳答案
我摆弄了它,似乎你应该将 goTo() 逻辑放在你想跳过的步骤上:
HTML
<div id="id1">One</div>
<div id="id2">Two</div>
<div id="id3">Three</div>
JS
var tour = new Tour();
tour.addSteps([
{
element:" #id1",
title: "1",
content: "1st Content.",
placement: "top",
onShow: function () {
console.log('This is Onshow Function');
},
},
{
element:" #id2",
title: "2",
content: "2nd Content",
placement: "top",
onShow: function () {
console.log('second step');
},
onShown: function () {
client_text = $('#id2').text();
if(client_text != ''){
console.log('----------client code present----------');
tour.goTo(2)
}
else{
console.log('-------client code not present--------');
}
},
},
{
element:" #id3",
title: "3",
content: "3rd Content",
placement: "top",
onShow: function () {
console.log('third step');
}
}
]);
tour.init();
tour.restart();
关于javascript - tour.goTo(i) 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23580275/