I have used the bootstrap carousal
and able to change the color of header background
using color thief
of one image only.
But in carousal there are multiple image changing with time.I am not able to get the image id from carousel for each image and set the color of header with changing of image using color thief .
This is the code I have tried, please tell me how to change the header background color according to change of carousal image. Thanks in advance
HTML
<section class="block">
<div style="padding:42px">
<div class="col-xs-12" style="border:15px solid rgb(250, 250, 250);padding: 0px;">
<div id="myDiv">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides (228, 226, 224) -->
<div class="carousel-inner reduce-height" role="listbox">
<div class="item active">
<img id="myimg" src="images/titanic.jpg" alt="Chania">
<div class="absolute-div">
<div class="carousel-caption">
<h3>Unforgettable Moments</h3>
</div>
</div>
</div>
<div class="item">
<img id="myimg2" src="images/beautiful-couple-widescreen.jpg" alt="Chania">
<div class="absolute-div">
<div class="carousel-caption">
<h3>Cherishable Memories</h3>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
This is my code for color thief and carousal
<script>
$(window).ready(function() {
$('.carousel').carousel({
interval: 3000
});
var sourceImage = document.getElementById("myimg");
var colorThief = new ColorThief();
var color = colorThief.getColor(sourceImage);
document.getElementById("mydiv").style.backgroundColor = "rgb(" + color + ")";
});
</script>