Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slick Slider - remove arrows from different slide views

I'm using slick.js to power a slider. I'd like to remove the "previous" arrow when the first slide is active and the "next" arrow when the last slide is active. I may need to remove both arrows when the final slide is active. Is there a slick event function or a jquery function that can do this?

like image 260
heytricia Avatar asked Feb 08 '23 18:02

heytricia


1 Answers

To disable previous arrow on first slide and next arrow on last slide you could define infinite : false, on slick initialization like below.

 $("#slider").slick({
        infinite : false
  });

if you have additional settings just include that in initialization. slider is id of container.

This is to disable arrows on Slider. To remove arrows you could just hide it when first/last slide is active. Go through documentation on how to get active slide on slider and with jquery hide you could hide arrow by class name of arrow button. You could get class/id of arrow button by inspecting element. Right click on arrow and inspect it.

To get current slide: $('#slider').slick('slickCurrentSlide');

To hide or show next arrow: $('.slick-next').show(); or $('.slick-next').hide();

Similarly for prev arrow: $('.slick-prev').show(); or $('.slick-prev').hide();

Heres Fiddle: https://jsfiddle.net/pjfw1wqz/

like image 198
pratikpawar Avatar answered Feb 13 '23 07:02

pratikpawar