How to Have Multiple Bootstrap Sliders on the Same Page!

Date: 07/12/2016, Author: Lostwake, Category: PHP Quick Reference

I have three carousels running at the same time, each with their own unique ID. They're being called using an attribute selector like so:

$('[id^="myCarousel"]').carousel();

So each carousel has an id that begins exactly with the ID of #myCarousel and then a number to set them apart.

But you can also define an instance for each carousel on the same line, for example: (Notice how each selector is separated by a comma.)

$('#myCarousel1, #myCarousel2, #differentCarousel3').carousel();

And it will work as well, so just make sure you use a valid selector for each instance of your carousels.

Source: stackoverflow

Comments: