admin管理员组文章数量:1335610
I am trying to append slick arrows to multiple containers. Basically, I need every slide to have its own navigation. Every slide has
<div class="pixoff-slider-navigation-anchor"></div>
somewhere inside it. My JS code is
$('.pixoff-slider-container').slick({
arrows: true
,appendArrows: $('.pixoff-slider-navigation-anchor')
});
This works, and it appends arrows to all the containers, but only latest set of arrows actually works. Other ones are just there and do nothing when we click on them.
I am trying to append slick arrows to multiple containers. Basically, I need every slide to have its own navigation. Every slide has
<div class="pixoff-slider-navigation-anchor"></div>
somewhere inside it. My JS code is
$('.pixoff-slider-container').slick({
arrows: true
,appendArrows: $('.pixoff-slider-navigation-anchor')
});
This works, and it appends arrows to all the containers, but only latest set of arrows actually works. Other ones are just there and do nothing when we click on them.
Share Improve this question edited Aug 29, 2018 at 9:13 Bahman Parsa Manesh 2,3703 gold badges18 silver badges36 bronze badges asked Aug 29, 2018 at 8:39 Milos911Milos911 4334 gold badges9 silver badges21 bronze badges 2- What is the click event for anchors? – Milind Anantwar Commented Aug 29, 2018 at 8:44
- I get what you are asking, but I am not sure how to check that? @MilindAnantwar – Milos911 Commented Aug 30, 2018 at 7:01
2 Answers
Reset to default 3If you are using several slider in one page, you should add additional script for this.
$(window).on("load resize orientationchange", function () {
$(".slider").each(function () {
var slider = $(this);
slider.slick({
centerMode: false,
centerPadding: '60px',
arrows: true,
dots: true,
slidesToShow: 3,
autoplay: true,
prevArrow: slider.parent().find('.btnPrev'),
nextArrow: slider.parent().find('.slider__btnNext'),
});
});
});
and HTML looks like this
<div class="sliderParent">
<button class="btnPrev"></button>
<button class="btnNext"></button>
<div class="slider">
<div class="item">a</div>
<div class="item">b</div>
<div class="item">c</div>
<div class="item">d</div>
</div>
</div>
Instead of appending the arrow to the dom, write the html you want in each slide and then set the prev and next arrows in your slick options.
$('.pixoff-slider-container').slick({
arrows: true,
dots: false,
prevArrow: $('.prev-arrow'),
nextArrow: $('.next-arrow')
});
<div class="pixoff-slider-navigation-anchor">
<a class="prev-arrow">Prev</a>
<a class="next-arrow">Next</a>
</div>
本文标签:
版权声明:本文标题:javascript - Slick slider appendArrows to multiple containers, arrows not working except last one - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742392731a2466309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论