Created
June 28, 2014 19:34
-
-
Save haydenjameslee/f016f097005a2d1d9a44 to your computer and use it in GitHub Desktop.
Bootstrap keep parent menu item highlighted when viewing its dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var initDropdownHover = function () { | |
// Add class to parent on mouseenter | |
$('.dropdown-menu').mouseenter(function() { | |
// If already active then don't do anythin | |
if (!$(this).hasClass('active')) { | |
// Get menu parent and add active class | |
var parent = $(this).closest('li.dropdown') | |
parent.addClass('active'); | |
// Remove added class | |
$('.dropdown-menu').mouseleave(function() { | |
parent.removeClass('active'); | |
}); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment