I have 3 bootstrap carousels (just one is visible, depending on what you click here):
All of them are working the same. If I click another slide, this is activated (adds class selected). It looks like this:
But when its auto-sliding to another slide, this slide doesnt show as activated (not adding class selected) and I dont know why its not working.
Question is regarding this page: https://bm-translations.de/km.php#video
my code:
// handles the carousel buttons
$('[id^=carousel-selector-]').click( function(){
var id_selector = $(this).attr("id");
var id = id_selector.substr(id_selector.length -1);
id = parseInt(id);
$('.carousel').carousel(id);
$('[id^=carousel-selector-]').removeClass('selected');
$(this).addClass('selected');
});
// when the carousel slides, auto update
$('.carousel').on('slide.bs.carousel', function (e) {
var id = $('.item.active').data('slide-number');
id = parseInt(id)+1;
$('[id^=carousel-selector-]').removeClass('selected');
$('[id=carousel-selector-'+id+']').addClass('selected');
});
On auto slide its not adding the class selected, but its doing on click. Whats wrong with my code?