jquery - show tab with external link with onclick in bootstrap 3 -
I want to link to a Bootstrap 3.2.0 tab with a link like this:
& lt; A href = "# tab_i_want_to_link" onclick = "something ()" & gt; Tab name & lt; / A & gt;
Thanks!
Here is a comment thread: and none of the solutions works like this well .
Source:
Demo:
This solution is outside of link tabs, inside, and wherever you are a regular Want with url
$ (window). Load tab ('click', 'a', function (e) {var = $ (This); // Prevent default behavior e.preventDefault (); // hash address bar window.location.hash = $ this.attr ('href'); // Clicked Tab $ this.tab Activate ('show');}); // tab will show hash based on hash function Refresh () {navbox.find ('a [href =' '+ window.location.hash +' "] ') The tab ('show');} // show tab, if the hash changes $ (window) in the address bar .bind ('hash change', refreshhash); // redd is from the address bar and show it HA is that if that show tab hash (window.location.hash) loaded on {// loaded ();}});
you have your bootstrap.js after those actions to this JS In which you call tooltip or powerover (for example). My document has bootstrap-initializations.js file loaded after bootstrap.min.js.
Usage: Like That you will use to link to an anchor:
& lt; a href = "mypage.html # tabID" & gt; Link & lt; / A & gt;
Comments
Post a Comment