

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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(); } });
- Related Questions & Answers
- How to prevent a dialog from closing when a button is clicked?
- How to prevent a dialog from closing when a button is clicked using Kotlin?
- Add a fading effect when closing an alert box in Bootstrap
- Bootstrap dropdown class
- Execute a script when the element is being clicked in HTML?
- Bootstrap class dropdown-header
- Execute a script when the element is being double-clicked in HTML?
- Tabs With Dropdown Bootstrap Example
- Create Dropdown menu with Bootstrap
- Change Color of Button in iOS when Clicked
- Execute a script when a reset button in a form is clicked in HTML?
- Right align a Bootstrap dropdown menu
- How to use Bootstrap Dropdown Plugins
- Disable a dropdown item with Bootstrap
- How to change color of Button in Android when Clicked?
Advertisements