I'm trying to attach a javascript event to the slick slider next and back buttons. I've tried inspecting the page and seeing what they're called and calling the event on those classes but it doesn't recognize the click event.
Here is the function I'm trying to call:
var i = 0;
$('.slick-next').click(function(){
console.log('next clicked');
i++;
console.log(i);
if (i==1) {
$('#people').css('filter', 'none');
}
})
I've tried using '.slick-next::before'
as well and that didn't work either
$("selector"). slick({ nextArrow: '<button type="button" class="btn btn-primary">prev</button>', prevArrow: '<button type="button" class="btn btn-primary">next</button>' });
CodePen Embed - slick-arrows. $(function(){ $("#slider"). slick({ speed: 1000, dots: true, prevArrow: '<button class="slide-arrow prev-arrow"></button>', nextArrow: '<button class="slide-arrow next-arrow"></button>' }); });
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators. Official documentation.
Need to add .on() method for the click of the button. That's because these next and previous arrow buttons are added later in the DOM by slick.js, and .on() can process events from descendant elements that are added to the document at a later time.
$('body').on('click', '.slick-arrow', function () {
alert('click working')
})
here is the codepen example
$('.slick-next').click(function(e){
console.log(e.target);
$('#people').css('filter', 'none');
})
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