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

119
Views
Bootstrap 5 Accordion Toggle not working In DOM

I am working on an RSS feed-based project where I have to render accordions dynamically using DOM manipulation.

It works fine on opening an accordion but does not get closed on toggling on the same accordion. Here's my function for rendering Accords based on some response data

const renderAccordionSection = (index, id, title) => {
  let divAccordion = `<div class="accordion-item">
                        <button class="accordion-button ${index === 0 ? "" : "collapsed"}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-${id}" aria-expanded="true" aria-controls="collapse-${id}">
                          ${title}
                        </button>
                        <div id="collapse-${id}" class="accordion-collapse collapse ${index === 0 ? "show": ""}" aria-labelledby="heading-${id}" data-bs-parent="#accordionId">
                          <div class="accordion-body">
                            <div id="indicator-${id}" class="carousel slide " data-bs-ride="carousel"> 
                              <div class="carousel-inner" id="carousel-inner-${id}">
                              </div>
                              <div>
                                <a class="carousel-control-prev" href="#indicator-${id}" role="button" data-bs-slide="prev">
                                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                                  <span class="sr-only">Previous</span>
                                </a>
                              </div>
                              <div>
                                <a class="carousel-control-next" href="#indicator-${id}" role="button" data-bs-slide="next">
                                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                                <span class="sr-only">Next</span>
                                </a>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>`;
  return divAccordion;
}
Ignore the accordion body. and an id "accordionId" is used to place the accords What could be the problem? I tried changing the bootstrap attributes but didn't work. Could use some help.

about 4 years ago · Santiago Gelvez
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!