How to Get Bootstrap Dropdown Menu to Show on Hover

I’ve been using Bootstrap for some time now, and absolutely love developing new sites and themes using the framework. However upon occasion there are some core functions that sometimes need alteration, and one of those is often the dropdown navigation menu.

By default Bootstrap will only show the navigation menu when the parent menu item is clicked, this is great if a parent item is a button as the users first instinct is to perform a click. However, when it comes to navigation we’ve all became quite accustomed to the hover effect.

There are several ways you can tackle this, and one of the most simple methods I use is to simply trigger a click action when the parent item gets hovered. To achieve this all is required is a simple piece of jQuery.

First, go take a look at the sample code for Bootstrap’s navigation menu and get to grips with how it’s structured. Then, add this simple piece of jQuery below to ┬ámake the drop-down show on hover.

[js light=”true”]<script>
$(‘.dropdown’).hover(function() {
$(‘.dropdown-toggle’, this).trigger(‘click’);

The code above assumes that your parent LI has the class “dropdown” assigned to it which then when hovered will trigger a click, which then triggers the default Bootstrap dropdown.

2017-05-08T09:52:57+00:00 June 30th, 2015|

Leave A Comment