经过几次研究和尝试,我终于找到了自己问题的答案。希望它会帮助别人。
我使用onNext()
和onPrev()
导航选项卡是正确的,但新选项卡的 div 仍然隐藏,需要额外的 JQuery。
将我的新选项卡$("").tab('show');
的属性从 更改为,然后简单地添加(或删除)一个类以使选项卡处于活动状态(或非活动状态)。display
none
block
$("").addClass("active");
$("").removeClass("active");
现在我必须说它就像一个魅力。这就是我的代码的样子:
var tour = new Tour({
name: "tour",
container: "body",
smartPlacement: true,
keyboard: true,
storage: false,
steps: [
{
element: "#tour1",
title: "Some title here",
content: "Some content here",
placement: "right"
},
{
element: "#tour2",
title: "Some title here",
content: "Some content here",
placement: "right"
},
{
element: "#tour3",
title: "Some title here",
content: "Some content here",
onNext:function(tour){
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(2) a").tab('show');
$("div.tab-pane:nth-child(2)").removeClass("active");
$("div.tab-pane:nth-child(4)").addClass("active");
}
},
{
element: "#tour4",
title: "Some title here",
placement: "right",
content: "Some content here",
onPrev:function(tour){
$("div.tab-pane:nth-child(4)").removeClass("active");
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(1) a").tab('show');
},
onNext:function(tour){
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(3) a").tab('show');
$("div.tab-pane:nth-child(4)").removeClass("active");
$("div.tab-pane:nth-child(6)").addClass("active");
}
},
{
element: "#tour5",
title: "Some title here",
placement: "right",
content: "Some content here",
onPrev:function(tour){
$("div.tab-pane:nth-child(6)").removeClass("active");
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(2) a").tab('show');
},
onNext:function(tour){
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(4) a").tab('show');
$("div.tab-pane:nth-child(6)").removeClass("active");
$("div.tab-pane:nth-child(8)").addClass("active");
}
},
{
element: "#tour6",
title: "Some title here",
placement: "right",
content: "Some content here",
onPrev:function(tour){
$("div.tab-pane:nth-child(8)").removeClass("active");
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(3) a").tab('show');
},
onNext:function(tour){
$("div.nav:nth-child(2) > ul:nth-child(1) > li:nth-child(4) a").tab('show');
$("div.tab-pane:nth-child(6)").removeClass("active");
$("div.tab-pane:nth-child(8)").addClass("active");
}
},
{
element: "#tour7",
title: "Some title here",
placement: "right",
content: "Some content here",
}
]
});