GreggMoore GreggMoore - 1 year ago 89
Javascript Question

Bootstrap keep menu open on outside click

I've exhausted most of the options I found here on Stack... I've created a full width (horizontal) dropdown menu using Bootstrap 3. The nav contains multiple dropdowns within itself and they are activated (displayed) by the mouseenter event:

if(!$('.navbar-toggle').is(':visible')) { // disable for mobile view
if(!$(this).hasClass('open')) { // Keeps it open when hover it again
$('.dropdown-toggle', this).trigger('click');

I've tried disabling the "outside" click by using:

$('#myDropdown').on('', function () {
return false;

which works, however, it also disables the "mouseenter" event.... How can I resolve this issue? Any feedback would be great! Thanks!

Answer Source

you meant like this?

i have added following code in addition with yours -

$(document).on('click',' a', function(){

hope that helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download