I am encountering an issue with multiple carousels on the same page. Utilizing bootstrap for my carousels, I noted that the carousel functions properly when there is only one present. However, when there are other carousels on the page, the slider loop malfunctions. Removing one carousel resolves this issue, despite renaming both carousel wrapper IDs and binding them in jQuery. The problem persists...
css
/*
Creative Commons 2.0 License - Attribution required
*/
@media (min-width: 768px) and (max-width: 991px) {
/* Code by Azmind.com */
}
...
HTML
<!-- Top content 1-->
<div class="top-content">
...
</div>
<!-- Top content 2 -->
<div class="top-content">
...
</div>
jQuery
/*
Carousel Functionality
*/
$('#carousel-example,#carousel-example-2').on('slide.bs.carousel', function (e) {
/*
CC 2.0 License - Attribution required
*/
var $e = $(e.relatedTarget);
var idx = $e.index();
var itemsPerSlide = 5;
var totalItems = $('.carousel-item').length;
if (idx >= totalItems-(itemsPerSlide-1)) {
// Append slides based on direction
}
});
https://i.sstatic.net/sREUD.png
How can I ensure each carousel loops independently without impacting others?