skip to Main Content

Javascript – How can I close the dropdown programmatically on button click?

I have the below Bootstrap 5 dropdown menu of labeled checkboxes, with data-bs-auto-close="outside", so that the menu closes on outside click. <div class="dropdown"> <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false"> Dropdown button </button> <div class="dropdown-menu"> <div class="px-1"> <input class="form-check-input"…

VIEW QUESTION

Html – How to activate first menu item on dropdown click in Bootstrap 5

Bootstrap 5 dropdown is defined as <div class="btn-group"> <button type="button" class="btn btn-danger dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> Action </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#"><u>A</u>ction</a></li> <li><a class="dropdown-item" href="#">A<u>n</u>other action</a></li> <li><a class="dropdown-item" href="#"><u>S</u>omething else here</a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="#">S<u>e</u>parated link</a></li> </ul> </div> https://jsfiddle.net/b6or2s5e/…

VIEW QUESTION

Javascript – bootstrap 5 click inside dropdown should not open close the dropdown

I have the following code <html> <head> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css"> <script src="https://code.jquery.com/jquery-3.7.1.slim.js"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button <i class="bi bi-x inside-button"></i> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li>…

VIEW QUESTION
Back To Top
Search