skip to Main Content

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

Getting the inner HTML value from the dropdown

I am using a Bootstrap dropdown like this: <ul class="dropdown-menu"> <li> <a class="dropdown-item" href="#" (click)="getMyValue('myvalue')">My Value</a> </li> <li> <a class="dropdown-item" href="#" (click)="getMyValue('someothervalue')">Some Other Label</a> </li> </ul> and the function looks like this: getMyValue(todo: string) { console.log("selected value is:", todo); console.log("selected…

VIEW QUESTION

Bootstrap 5.3 events not working in jQuery .on event

This is such an odd issue. I've never had any issues like this before... Here is my dropdown... $('#mydropdown').on('show.bs.dropdown', function() { console.log('hit 1'); }); $(document).on('show.bs.dropdown', '#mydropdown', function() { console.log('hit 2'); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/> <div class="dropdown" id="mydropdown">…

VIEW QUESTION
Back To Top
Search