How to get a slide element in an event, in Slick Carousel?

Yuval A. picture Yuval A. · Mar 18, 2015 · Viewed 22.7k times · Source

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....

Answer

Abraham Uribe picture Abraham Uribe · Mar 18, 2015

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"