Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Bootstrap's dropdown on hover?

How can I make twitter bootstrap's menu dropdown be on hover instead of a click?

like image 437
Sol Orwell Avatar asked Nov 06 '12 03:11

Sol Orwell


People also ask

How do you make a drop down hover?

Example ExplainedUse any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.

How do you toggle a dropdown in Bootstrap?

Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown JavaScript plugin. They're toggled by clicking, not by hovering; this is an intentional design decision.

How do I create a dropdown in Bootstrap?

To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.


2 Answers

1.Hide dropdown-menu on mouseover.

$(document).ready(function() {     $('.nav li.dropdown').hover(function() {         $(this).addClass('open');     }, function() {         $(this).removeClass('open');     }); }); 

2.Hide dropdown-menu on click.

$(document).ready(function() {     $('.nav li.dropdown').hover(function() {         $(this).addClass('open');     }); }); 

http://jsfiddle.net/7yMsQ/1/

like image 188
Alex Zhdanov Avatar answered Oct 07 '22 10:10

Alex Zhdanov


heres a function I'm using to get the navbar dropdowns to slide down on hover instead of just popping in

$('.navbar .dropdown').hover(function() {   $(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown(); }, function() {   $(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp() }); 
like image 30
Yohn Avatar answered Oct 07 '22 08:10

Yohn