jquery - Bootstrap 3 - Control a Nav Panel with 2 Identical Nav Tabs - Update active class for both -
I have bootstrap tabs, but there are several nav tabs to control a nav pane - a set of navs at the top Tabs, and under the tab panel. The code below works if I click on Navigation-Tab 2, but does not update Nav-Tab 1 with the correct 'Active tab'.
Does anyone have any idea how to achieve this? Thanks!
& lt ;! - Navigation tab 1 - & gt; & Lt; Div class = "concentrated pills" & gt; & Lt; Ul class = "nav nav-pills" & gt; & Lt; Li class = "active" & gt; & Lt; A href = "#a" data-toggle = "tab" & gt; & Lt; Span & gt; Style & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# b" data-toggle = "tab" & gt; & Lt; Span & gt; B & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# c" data-toggle = "tab" & gt; & Lt; Span & gt; C & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt ;! - End focused pills - & gt; & Lt; Div class = "tab-content" & gt; & Lt; Div class = "active in tab-palette active" id = "a" & gt; & Lt; / Div & gt; & Lt; Div class = "fade in tab-pen" id = "b" & gt; & Lt; / Div & gt; & Lt; Div class = "fade in tab-pen" id = "b" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - End tab-content - & gt; & Lt ;! - Navigation tab 2 - & gt; & Lt; Div class = "concentrated pills" & gt; & Lt; Ul class = "nav nav-pills" & gt; & Lt; Li class = "active" & gt; & Lt; A href = "#a" data-toggle = "tab" & gt; & Lt; Span & gt; Style & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# b" data-toggle = "tab" & gt; & Lt; Span & gt; B & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "# c" data-toggle = "tab" & gt; & Lt; Span & gt; C & lt; / Span & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt ;! - End focused pills - & gt;
This is working for me
$ (Document) .ready (function () {if (location.hash) {$ ('a [href =' + location.hash + ']'). Tab ('show');} $ (document.body) ("Click", "a [data-toggle]", function (event) {location.hash = this.getAttribute ("href");});}); $ (Window) .on ('popstate', function) {var anchor = location.hash || $ ("A [data-toggle = tab]") first (). Attr ("href"); $ ('A [href =' + anchor + ']'). Tab ('show');});
Comments
Post a Comment