jQuery Plugin To Toggle Bootstrap Dropdowns On Hover

jQuery Plugin To Toggle Bootstrap Dropdowns On Hover

A simple jQuery plugin which allows the visitor to toggle Bootstrap's native dropdown menus on hover, on click or both.

Supports both Bootstrap 4 and Bootstrap 3 framework.

Additional features:

  • Maintains Bootstrap dropdowns' native functions.
  • Auto close dropdown menu after a time out.

See also:

How to use it:

1. Load the jquery.bootstrap-dropdown-hover.js script in your Bootstrap project, after jQuery JavaScript library.

<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="jquery.bootstrap-dropdown-hover.js"></script>

2. Call the function on the Bootstrap dropdown menu.

$('[data-toggle="dropdown"]').bootstrapDropdownHover();

3. Config the plugin.

// Click behavior setting:
// 'default': the dropdown toggles on hover and on click too
// 'disable: disables dropdown toggling with clicking when mouse is detected
// 'sticky': if we click on an opened dropdown then it will not hide on mouseleave but on a second click only
clickBehavior: 'sticky', 
// how much time the hovered dropdown hides after mouseleave
hideTimeout: 200

Change log:

2018-04-10

  • Updated for Bootstrap 4

This awesome jQuery plugin is developed by istvan-ujjmeszaros. For more Advanced Usages, please check the demo page or visit the official website.

  • Publication date: 10.04.2018
  • Source