Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
How to alert data when bootstrap5 dropdown menu is closed

Am trying to alert data when Bootstrap5 Dropdown menu is closed but cannot get it to work. Below is what i have tried

 <div class="dropdown">
  <button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">
    Dropdown button
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Link 1</a></li>
    <li><a class="dropdown-item" href="#">Link 2</a></li>
    <li><a class="dropdown-item" href="#">Link 3</a></li>
  </ul>
</div> 




$('.dropdown-menu').on("hide.bs.dropdown", function () {

   alert('Dropdown Menu is closed');               
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is not working because you are trying to run the function on ul elements, where as you should be running the eventlistenner on button element. I would suggest you to use id on that particular dropdown element.

$('.dropdown-toggle').on("hide.bs.dropdown", function () {
   alert('Dropdown Menu is closed');               
});

Here is the working example for your code. I have just added the id to the button element.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!