问题
I've tried CSS tricks to try and keep the tabs to stay appearing, but everything I click a tab - it disappears as soon as I click onto another tab.
I tried moving the JS code around and moving certain CSS attributes to the bottom of the page, beneath the tab code; nothing happens.
Could it be possible that because I have a tab on the header, that it's doing this?
the code and tabs together looks ok, no misspellings.
回答1:
$(document).off('click.tab.data-api');
$(document).on('click.tab.data-api', '[data-toggle="tab"]', function (e) {
e.preventDefault();
var tab = $($(this).attr('href'));
var activate = !tab.hasClass('active');
$('div.tab-content>div.tab-pane.active').removeClass('active');
$('ul.nav.nav-tabs>li.active').removeClass('active');
if (activate) {
$(this).tab('show')
}
});
回答2:
In my case it was an incompatibility with prototype :(
来源:https://stackoverflow.com/questions/35186082/bootstrap-tabs-disappear-after-clicking-onto-another-tab