Bootstrap dropdown closing when clicked in HTML

HTMLBootstrapWeb DevelopmentFront End Technology

As you may have seen, whenever you open a dropdown, and click anywhere else, the dropdown close. 

By using the below given code, the dropdown menu can be kept open after click−

$('#myDropdown').on('hide.bs.dropdown', function () {
   return false;
});

Another option is to handle the clickevent −

The click event can also be handled byusing the following code. The event.stopPropagation() method stopsthe bubbling of an event to parent elements. It prevents any parentevent handlers from being executed −

$('#myDropdown .dropdown-menu').on({
   "click":function(e) {
       e.stopPropagation();
    }
});
raja
Published on 20-Mar-2018 15:45:52
Advertisements