Slick Carousel: http://kenwheeler.github.io/slick/
How can I get the element of the slide in an event? For example:
.on('afterChange', function (slick, currentSlide)
{
var currentSlideElement = //Get current slide element here
});
The first argument seems to be the event
object, but its target
(or currentTarget
) is always the slides container, and second argument seems to be the slick object....
you need to include the first argument "event" like this
$('.your-element').on('afterChange', function(event, slick, currentSlide){
console.log(currentSlide);
});
or else your "currentSlide" argument will be "slick"
To get the DOM element on 'afterChange' event:
$('.your-element').on('afterChange', function (event, slick, currentSlide) {
var elt = slick.$slides.get(currentSlide);
});
// Get the current slide
var currentSlide = $('.your-element').slick('slickCurrentSlide');
Source: https://github.com/kenwheeler/slick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With