Answer the question
In order to leave comments, you need to log in
How to remove the error "Cannot read property 'unslick' of undefined" when initializing slick slider?
There was a task to initialize the slick slider on screens less than 500px, respectively, on screens greater than 500px, turn it off.
Found this solution:
$(window).on("load resize", function(){
var width = $(document).width();
if (width > 500) {
$('.profit-row, .plan-row, .teachers-slider').slick('unslick');
} else {
$('.profit-row, .plan-row, .teachers-slider').not('.slick-initialized').slick({
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
});
}
});
<link rel="stylesheet" href="slick/slick.css"/>
<link rel="stylesheet" href="slick/slick-theme.css"/>
<script src="slick/slick.min.js"></script>
$('.your-slider').slick('unslick');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question