Is it possible to change css for a div on slick.js slider change? Basically if the slider autoplays or from button click I'd like to cycle through an array of colors and set the background color of .content to that color. Am I being too crazy?
var colors = ['#576986', '#D0D5D6', '#DFDEE5'];
$('.content').css({'background': current i++});
Check out the demo jsfiddle
Any ideas? :)
Is it possible to change css for a div on slick.js slider change? Basically if the slider autoplays or from button click I'd like to cycle through an array of colors and set the background color of .content to that color. Am I being too crazy?
var colors = ['#576986', '#D0D5D6', '#DFDEE5'];
$('.content').css({'background': current i++});
Check out the demo jsfiddle
Any ideas? :)
Share Improve this question asked Feb 7, 2017 at 4:47 meow-meow-meowmeow-meow-meow 5182 gold badges10 silver badges26 bronze badges1 Answer
Reset to default 13Slick has events, you can find the full list here: https://github.com/kenwheeler/slick
$(".slider").on("beforeChange", function (){
//change color here
})
To cycle through colors:
var colors = ["red", "orange", "yellow", "green", "blue"];
var currentIndex = 0;
$(".slider").on("beforeChange", function (){
$(".content").css("background-color", colors[currentIndex++%colors.length]);
});