How to add slick slider for the desired screen resolution? Slider initialization:
$('.slider').slick({ accessibility: true, autoplay: true, }); I add the required class at the specified resolution to initialize the slider:
function replaceClass(){ var block = document.querySelector(".block"); if (window.matchMedia('(max-width: 500px)').matches) { block.classList.add('slider'); } else { block.classList.remove('slider'); } }; replaceClass(); $(window).resize(replaceClass); But then, if you increase the width> 500 px, the class 'slider' is removed from the block, but the slider still remains to hang on the block ((Thank you !!