I want to change the active bootstrap tab on the click of another button.
我想在点击另一个按钮时更改活动引导选项卡。
I have tried add id's to the tabs li and write custom jquery code.
我尝试将标签添加到标签li并编写自定义jquery代码。
$('#emailNotify').click(function () {
$('#notify').addClass('active').attr('aria-expanded','true');
$('#myacc').removeClass('active').attr('aria-expanded','false');
});
This code works fine on first click but it doesn't change back when I tried to click My Account tab again.
此代码在第一次单击时工作正常,但当我再次单击“我的帐户”选项卡时,它不会更改。
Markup:
<ul class="content-list museo_sans500">
<li><a href="javascript:void(0)">Change Password</a></li>
<li><a id="emailNotify" data-toggle="tab">Change Email Notifications</a></li>
<li><a href="javascript:void(0)">Change Profile Picture</a></li>
</ul>
2 个解决方案
#1
25
You can change the active tab on the click event button with that:
您可以使用以下命令更改单击事件按钮上的活动选项卡:
$('#changetabbutton').click(function(e){
e.preventDefault();
$('#mytabs a[href="#second"]').tab('show');
})
Here's a JSFiddle with an example:
这是一个带有示例的JSFiddle:
#2
1
You should use twitter-boostrap way to change between tabs:
您应该使用twitter-boostrap方式在标签之间进行更改:
$('#myTab a:first').tab('show'); // Select first tab
$('#myTab a:last').tab('show'); // Select last tab
or
$('#notify').tab('show'); // show notification tab
#1
25
You can change the active tab on the click event button with that:
您可以使用以下命令更改单击事件按钮上的活动选项卡:
$('#changetabbutton').click(function(e){
e.preventDefault();
$('#mytabs a[href="#second"]').tab('show');
})
Here's a JSFiddle with an example:
这是一个带有示例的JSFiddle:
#2
1
You should use twitter-boostrap way to change between tabs:
您应该使用twitter-boostrap方式在标签之间进行更改:
$('#myTab a:first').tab('show'); // Select first tab
$('#myTab a:last').tab('show'); // Select last tab
or
$('#notify').tab('show'); // show notification tab