Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  148] [ 1]  / answers: 1 / hits: 61399  / 9 Years ago, tue, september 1, 2015, 12:00:00

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.



$('#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.



Image



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>

More From » jquery

 Answers
39

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:



http://jsfiddle.net/4ns0mdcf/


[#65226] Sunday, August 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;