How can I detect if jQuery lightslider has been instantiated, and how to clear instance if yes

后端 未结 2 343
误落风尘
误落风尘 2021-01-23 15:05

I\'m using JQuery lightSlider. It works pretty well (well, actually, I had to jig the code a little bit, but enough of that for now).

What I am trying to achieve is to d

2条回答
  •  情歌与酒
    2021-01-23 16:09

    Assuming you are using a newer version of lightslider than 1.1.3 you should be able to .destroy() the existing instance as follows:

    var slider = $('#lightslider').lightSlider();
    slider.destroy();   
    

    For safety, you will need to check the slider is something before you call the destroy method though!

提交回复
热议问题