我是第一次使用slick轮播,我的问题是slickPrev方法在beforeChange事件中不起作用。
这是代码
var assessSlider = $('.assess-health__slick');
assessSlider.on('beforeChange', function(slick, currentSlide, nextSlide){
if($("input[name='qid-1']:checked").val() == undefined){
assessSlider.slick('slickPrev');
//var currentSlider = assessSlider.slick('slickCurrentSlide');
//console.log(currentSlider);
//assessSlider.slick('slickGoTo', currentSlider);
}
});
<div class="assess-health__question index-0">
<p>this is question 1111111</p>
<div class="assess-health__question__item">
<input type="radio" name="qid-1" value="男">
<label>男</label>
</div>
<div class="assess-health__question__item">
<input type="radio" name="qid-1" value="女">
<label>女</label>
</div>
</div>
救救我!