Created
March 20, 2017 23:53
-
-
Save lewebsimple/6121d35a5977cb036b08c8d9bdb94726 to your computer and use it in GitHub Desktop.
[Bootstrap 4] Dropdown navbar menu on hover
This file contains hidden or 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
// Dropdown navbar menu on hover | |
$('.dropdown-menu', this).css('margin-top', 0); | |
$('.dropdown').hover(function () { | |
$('.dropdown-toggle', this).trigger('click').toggleClass("disabled"); | |
}); |
Works. Thanks!
$('.dropdown-toggle').hover(function () { $(this).trigger('click').toggleClass("disabled"); });
I think that's better
The second solution avoids the UX annoyance where the menu disappears when you try to re-enter after leaving (because it doesn't catch the original mouseleave
event for some reason.
But the menu still stays open after leaving the drop down. Also, there a bad toggle when hovering over the main menu item from the dropdown.
Eventually went this with this, as it avoids all those issues and is pure CSS :)
.dropdown-menu {
margin: 0;
}
.dropdown:hover > .dropdown-menu {
display: block;
}
$('.dropdown-toggle').hover(function () { $(this).trigger('click').toggleClass("disabled"); });
I think that's better
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i try this it is notworking