Home > Article > Web Front-end > Close Bootstrap dropdown menu on click in HTML
As you can see, whenever you open the dropdown and click anywhere else, the dropdown closes.
By using the code given below, the dropdown menu can stay open after click −
$('#myDropdown').on('hide.bs.dropdown', function () { return false; });
Another option is to handle the click event –
Click event is also possible Handled by using the following code. The event.stopPropagation() method stops event bubbling to the parent element. It prevents any parent event handler from executing -
$('#myDropdown .dropdown-menu').on({ "click":function(e) { e.stopPropagation(); } });
The above is the detailed content of Close Bootstrap dropdown menu on click in HTML. For more information, please follow other related articles on the PHP Chinese website!