0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

slick.js dotsの表示/非表示を動的に変更する

Posted at

やりたいこと

写真が複数枚のときはdotsを表示したい。
写真が1枚のときはdotsを非表示にしたい。
以下のように。
image.png  image.png

方法

$(function () {
  $('.slider').on('init', function (event, slick) {
    if (slick.slideCount <= 1) {
      // bootstrap使っているのでaddClass()で対応
      $(this).find('.slick-dots').addClass('d-none');
    }
    
  });
  $('.slider').slick({
    dots: true
  });
});

わりとシンプルなのに、たどり着くのに1時間以上かかってしまった。
精進します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?