Skip to content

Instantly share code, notes, and snippets.

@AlexeyKuzmich
Last active December 1, 2017 08:10
Show Gist options
  • Save AlexeyKuzmich/13c4f282f9c7bc97774b8639c072b4f5 to your computer and use it in GitHub Desktop.
Save AlexeyKuzmich/13c4f282f9c7bc97774b8639c072b4f5 to your computer and use it in GitHub Desktop.
Bootstrap nav menu hack
/**
* Bootstrap nav menu hack
*/
$(window).on('load', function () {
// On page load
if ($(window).width() < 768) {
$('.navbar-nav > li > .dropdown-toggle').removeAttr('data-hover').attr('data-toggle', 'dropdown');
}
// On window resize
$(window).resize(function () {
if ($(window).width() < 768) {
$('.navbar-nav > li > .dropdown-toggle').removeAttr('data-hover').attr('data-toggle', 'dropdown');
} else {
$('.navbar-nav > li > .dropdown-toggle').removeAttr('data-toggle').attr('data-hover', 'dropdown');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment