I am looking for a solution to get the width of window outside the $(window).resize
function. I am working on a slider and want to make changes to its slidesToShow
property.
I want the width value in the $jq('.autoplay').slick
function to change the value of slidesToShow
. If the width is less than 1000
slidesToShow value must be 2
etc.
I have taken help from this link but it's not working for me.
var $jq = jQuery.noConflict();
$jq(document).on('ready', function() {
$jq(window).resize(function() {
var width = $jq(window).width();
});
$jq('.autoplay').slick({
slidesToShow: 3,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
prevArrow: '<div class="slick-prev"><i class="lni-chevron-left"></i></div>',
nextArrow: '<div class="slick-next"><i class="lni-chevron-right"></i></div>'
});
});