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

slick slider example
slick slider vertical
slick js cdn
slick get current slide index
jquery carousel
slick slider click event
slider js
react-slick get current slide

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"

Fully Responsive & Flexible jQuery Carousel Plugin, you need to include the first argument "event" like this $('.your-element').on('​afterChange', function(event, slick, currentSlide){ console.log(currentSlide); });. .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.

To get the DOM element on 'afterChange' event:

$('.your-element').on('afterChange', function (event, slick, currentSlide) {
    var elt = slick.$slides.get(currentSlide);
});

javascript, slick is a responsive carousel jQuery plugin that supports multiple breakpoints, CSS3 transitions, touch events/swiping & much more! data-slick attribute. You still need to call $(element).slick() to initialize slick on the element. Previous Note: the HTML tag or the parent of the slider must have the attribute "dir" set to "​rtl". I created a vertical carousel with Slick. I made some changes in design and everything is working as I wanted except when the first element is in the view of the carousel. At a time there are 4 ite

// Get the current slide
var currentSlide = $('.your-element').slick('slickCurrentSlide');

slick - the last carousel you'll ever need, $('element-in-slickslide').on('click', function(event) { event.preventDefault(); I am getting undefined for $('your-slider').slick.$slides. This also  How can I know what direction the carousel are going on the event onBeforeChange. right or left? $('.foo').slick infinite: false onBeforeChange: (e) -> if right do_this() if left do_that() Slick Carousel

The 'currentSlide' parameter does not work as expected if you are displaying multiple slides at once.

The way I have found in this instance is with the 'slick-current' class that gets added to the current slide.

e.g. where slider is the HTML element wrapper for you carousel:

$('.your-element').on('afterChange', function(event, slick, currentPage){
    var currentIndex = parseInt(slider.querySelector('.slick-current').getAttribute('data-slick-index'));
}); 

how to get the index of the slide clicked? · Issue #149 · kenwheeler , Can't destroy slick - unslick function returns error #369 I used $("[data-slick-​index='" +currentSlide+ "']").attr('id') to get the current $('#carousel').on('​afterChange', function(event, slick, currentSlide, nextSlide){ console.log($(slick. to the next/previous slide - instead it gets applied to the first element. slick is a responsive carousel jQuery plugin that supports multiple breakpoints, CSS3 transitions, touch events/swiping & much more!

Accessing Current Slide Attributes in onAfterChange · Issue #411 , You still need to call $(element).slick() to initialize slick on the element. hit destroy | event, slick | When slider is destroyed, or unslicked. edge | event, slick, Add a slide $('.your-element').slick('slickAdd',"<div></div>"); // Get the current slide  The data-ride="carousel" attribute tells Bootstrap to begin animating the carousel immediately when the page loads. The "Indicators" part: The indicators are the little dots at the bottom of each slide (which indicates how many slides there are in the carousel, and which slide the user is currently viewing).

slick ------- [1]: <https://github.com/kenwheeler/slick> _the last , NPM package for Ken Wheeler's Slick-Carousel. npm install slick-carousel You still need to call $(element).slick() to initialize slick on the element. afterChange, event, slick, currentSlide, After slide change callback. Inside that event we add the is-transitioned class to the elements of the first slide. It’s important to note that this event must be attached before carousel’s initialization. Preventing the Page Jump on Load. Before moving on, let’s cover one tricky thing.

slick-slider, Slick Carousel: http://kenwheeler.github.io/slick/. How can I get the element of the slide in an event? For example: .on('afterChange', function  Before slide change callback: breakpoint: event, slick, breakpoint: Fires after a breakpoint is hit: destroy: event, slick: When slider is destroyed, or unslicked. edge: event, slick, direction: Fires when an edge is overscrolled in non-infinite mode. init: event, slick: When Slick initializes for the first time callback. Note that this event

Comments
  • Thanks. Your answer helped me towards the right direction. currentSlide returns a number, and then I can select the element via the data-slick-index attribute, e.g. $("[data-slick-index='"+currentSlide+"']);.
  • Is there a way to access previous slide on afterChange event?
  • @max: $("[data-slick-index='"+(currentSlide-1)+"']);
  • @YuvalA that won't work when moving back a slide or when using slickGoTo