Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Bootstrap dropdown closing when clicked in HTML
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();
}
}); Advertisements
