- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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(); } });
Advertisements