1

I want dropdown-menu to appear on mouse hover. Here is jsbin of my code: link

Tried jquery:

$('.dropdown-toggle').hover(
    function() {
        $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn();
    }
);
$('.dropdown-menu').hover(
    function() {
        $(this).stop(true, true);
    },
    function() {
        $(this).stop(true, true).delay(200).fadeOut();
    }
);

But it is not working...

3 Answers 3

1

In Bootstrap Dropdown with Hover this is fixed using CSS instead of JavaScript. If you change the solution of the accepted answer into

.navbar .btn-group:hover > .dropdown-menu {
    display: block;
}

it should work with your example code.

Sign up to request clarification or add additional context in comments.

2 Comments

But dropdown menu is disappearing
Good point :D! I've changed the CSS to look at the .btn-group instead of the button as the .btn-group contains both the button and the dropdown-menu. the > is needed as there is another .btn-group around all buttons, so without it hovering any button would open all menu's :)
0

You can use inner Bootstrap API:

$(document)
   .on('hover', '.dropdown-toggle', Dropdown.prototype.toggle)

Comments

0

Try this

jQuery(function ($) {
    $('.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();
    });
    $('.navbar .dropdown > a').click(function () {
        location.href = this.href;
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.