【问题标题】:Why is slick slider setoption not working?Why is slick slider setoption not working?
【发布时间】:2022-12-02 10:43:56
【问题描述】:

Trying to use slickSetOption to set autoplay to true, will have this trigger another way eventually. But the problem is that when I try to use slickSetOption nothing happens. Any idea what I'm doing wrong here?

  $(".slick-slider").slick({
   slidesToShow: 3,
   infinite:false,
   slidesToScroll: 1,
   autoplay: false,
   autoplaySpeed: 2000
  });
  
 $(".slick-slider").slick("slickSetOption", "autoplay", true, false);

【问题讨论】:

    标签: javascript jquery slick.js


    【解决方案1】:

    The slickSetOption method is used to change the options of the slider after it has been initialized.

    To use slickSetOption, you need to pass the option you want to change as the first argument, and the new value as the second argument. In your code, you're trying to set the autoplay option to true, but you're passing the value as the third argument, not the second.

    Try changing your code to this (not tested):

    $(".slick-slider").slick({
      slidesToShow: 3,
      infinite: false,
      slidesToScroll: 1,
      autoplay: false,
      autoplaySpeed: 2000
    });
    
    $(".slick-slider").slick("slickSetOption", "autoplay", true);
    

    【讨论】:

      猜你喜欢
      • 2022-11-20
      • 2022-12-02
      • 2022-01-03
      • 2022-11-20
      • 1970-01-01
      • 2020-05-09
      • 2013-01-26
      • 1970-01-01
      • 2015-10-25
      相关资源
      最近更新 更多