我正在使用Flex滑块。我合并了两个flexslider,并为两个滑块提供了一个滑块控件。在这里一切正常,但是滑动控件我想将活动类添加到自定义滑动控件中。谁能建议我该怎么办?
jQuery(document).ready(function($) {
$('#main-slider').flexslider({
animation: "slide",
slideshow: true,
slideToStart: 0,
direction: "vertical",
reverse: true,
start: function(slider) {
$('a.slide_thumb').click(function() {
$('.flexslider').show();
var slideTo = $(this).attr("rel") //Grab rel value from link;
var slideToInt = parseInt(slideTo) //Make sure that this value is an integer;
if (slider.currentSlide != slideToInt) {
slider.flexAnimate(slideToInt) //move the slider to the correct slide (Unless the slider is also already showing the slide we want);
}
});
}
});
$('#secondary-slider').flexslider({
//animation: "fade",
animationSpeed: 50,
slideshow: true,
slideToStart: 0,
direction: "vertical",
reverse: true,
start: function(slider) {
$('a.slide_thumb').click(function() {
$('.flexslider').show();
var slideTo = $(this).attr("rel"); //Grab rel value from link;
var slideToInt = parseInt(slideTo) //Make sure that this value is an integer;
if (slider.currentSlide != slideToInt) {
slider.flexAnimate(slideToInt) //move the slider to the correct slide (Unless the slider is also already showing the slide we want);
}
});
},
before: function() {
$('.flex-caption.flex-active-slide').addClass("animated fadeInUp");
$('.flex-caption.flex-active-slide').attr('style', 'display: block !important');
$('.flex-caption').hide();
},
after: function(slider) {
$('.flex-caption.flex-active-slide').addClass("animated fadeInUp");
$('.flex-caption.flex-active-slide').attr('style', 'display: block !important');
},
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.1/jquery.flexslider-min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.1/flexslider.css" rel="stylesheet" />
<div class="sliders-wrap">
<div class="sliders">
<div id="main-slider" class="flexslider">
<ul class="slides">
<li>
<img src="https://preview.ibb.co/ewNfK9/3.jpg" />
</li>
<li>
<img src="https://preview.ibb.co/kRYnz9/2.jpg" />
</li>
<li>
<img src="https://preview.ibb.co/hGx86p/1.jpg" />
</li>
<li>
<img src="https://preview.ibb.co/f0ANXU/4.jpg" />
</li>
</ul>
</div>
<div id="secondary-slider" class="flexslider">
<ul class="slides">
<li class="flex-caption">
<p>Timberland Makes the best Shoes shoes</p>
</li>
<li class="flex-caption">
<p>Keep it trendy with Converse</p>
</li>
<li class="flex-caption">
<p>Timberland Makes the best Shoes shoes</p>
</li>
<li class="flex-caption">
<p>Keep it trendy with Converse</p>
</li>
</ul>
</div>
<div class="slider-controls">
<!-- custom slide controls same for the both sliders -->
<div class="custom-direction-nav">
<a rel="0" class="slide_thumb" href="#">01</a>
<a rel="1" class="slide_thumb" href="#">02</a>
<a rel="2" class="slide_thumb" href="#">03</a>
<a rel="3" class="slide_thumb" href="#">04</a>
</div>
</div>
</div>
</div>
custom-direction-nav
onclick运行正常,我只想在此处添加活动类。