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

260
Views
How can I do something as soon as a collapse item is closed?

In the Bootstrap 5 documentation it says: You can create a collapse instance with the constructor, for example:

var myCollapse = document.getElementById('myCollapse')
var bsCollapse = new bootstrap.Collapse(myCollapse, {
  toggle: false
})

I need to close it on the click of a certain element and so I did so

document.body.addEventListener("click", el => {
  if (el.target.matches("#send-search")) {
    el.preventDefault();

    // Closing element
    new bootstrap.Collapse(document.querySelector("#find-el"), {
      hide: true,
    });

    // Do stuff do stuff when it is completely closed

  }
});

the element closes...

what I need is to perform a certain operation but only when the element is completely closed

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can attach a listener for the hidden.bs.collapse event...

myCollapse.addEventListener('hidden.bs.collapse', function () {
    console.log('closed!')
})

Demo: https://codeply.com/p/uSKVzr7uYT

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!