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

120
Views
How to make Bootstrap 5 carousel dynamic (indicators & first item active class)?

I wander how to have a Bootstrap 5 carousel dynamic. I mean how to dynamically display indicators and add active class to first item of carousel.

In Bootstrap 4 is like that:

$('#main_carousel .carousel-item:first').addClass('active');
var myCarousel = $("#main_carousel");
myCarousel.append("<ol class='carousel-indicators d-none d-xl-flex'></ol>");
var indicators = $("#main_carousel .carousel-indicators");
myCarousel.find(".carousel-inner").children(".carousel-item").each(function(index) {
  (index === 0) ?
  indicators.append("<li data-target='#main_carousel' data-slide-to='"+index+"' class='active'></li>") :
  indicators.append("<li data-target='#main_carousel' data-slide-to='"+index+"'></li>");
});

How to do that in vanilla js for bootstrap 5?

thank you

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