Skip to content

Instantly share code, notes, and snippets.

@johnpdang
Created May 9, 2020 23:38
Show Gist options
  • Save johnpdang/bfbdefc176675990f6d7c31cfa4634a5 to your computer and use it in GitHub Desktop.
Save johnpdang/bfbdefc176675990f6d7c31cfa4634a5 to your computer and use it in GitHub Desktop.
Tabs
const tabs = () => {
$(".nav-tabs a").click(function () {
$('.nav-tabs a').removeClass('active');
$(this).tab('show').blur().addClass('active');
const link_text = $(this).html();
const tab_trigger = $(this).closest('.tabs-dropdown-wrap').prev('.tab-dropdown-trigger');
tab_trigger.html(link_text);
if($(window).innerWidth() < 991){
$(this).closest('.tabs-dropdown-wrap').slideUp();
tab_trigger.removeClass('active');
}
});
$('.tab-dropdown-trigger').click(function(e){
e.preventDefault();
$(this).blur().toggleClass('active');
$(this).next('.tabs-dropdown-wrap').slideToggle();
});
}
export default tabs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment