A framework for adding, remove, renaming and in general handling Twitter Bootstrap Tabs through JavaScript.
Modified by Bowei:
-
Enhance the stability of tab assessment
-
Add functions ‘moveForward` and `moveBackward`
@nick322 has set up this exelent JS Fiddle: jsfiddle.net/0ua2gzyc/
Require the single JavaScript file.
tabs = $("ul.nav-tabs") tabs.addBSTab("id_of_tab", "Tab title", "<b>Content</b>")
You can also add it by an element already defined (maybe as hidden?):
tabs.addBSTab("id_of_tab", "Tab title", $("#my_element_id"))
tab = tabs.getBSTabByID("id_of_tab") tab.removeBSTab()
tab = tabs.getBSTabByID("id_of_tab") tab.renameBSTab("New title")
a.click(function(){ tab = $(this).currentBSTab() })
a.click(function(){ tab_id = $(this).currentBSTabID() })
tab = tabs.getBSTabByID("id_of_tab"); tab.moveForward(); //tab.moveBackward(); //Or use this to move tab till the 'bound' item //使用此传入参数,可以设置向前移动的'界限' tab.moveForward("idToForbid");