I'm pretty new to code and programming, but I'm playing around to learn some tools for web development. I've tried to make a bootstrap carousel trigger a change in text beside it and succeeded (see code below). But I also want it to have the same transition property as the carousel, which is a 1.5s fade out and in. However, I can only make the div (with the different text) appear and disappear instantaneously. If I add any jQuery fade() or slide() it will act as if I'm pressing a link to the carousel-ID.
This is the code I have for triggering hide/show for the div. I began with just the top part of the script, but played around with the second to see if I could get a different result.
$("#carouselExampleIndicators").on('slide.bs.carousel', function(event){
let image = (event.to);
if (image == 1) {
$("#header-1").hide();
$("#header-3").hide();
}
else if (image == 2) {
$("#header-1").hide();
$("#header-2").hide();
}
else {
$("#header-2").hide();
$("#header-3").hide();
}
});
$("#carouselExampleIndicators").on('slid.bs.carousel', function(event){
let image = (event.to);
if (image == 1) {
$("#header-2").show();
}
else if (image == 2) {
$("#header-3").show();
}
else {
$("#header-1").show();
}
});
</script>
Any tips?