[英]Add flex-active class to li then remove when slider advances
I found a similar question Adding flex-active class to the li instead of a/img 我发现了类似的问题将flex-active类添加到li而不是a / img
but this solution is not removing the flex-active class from the active li siblings. 但是此解决方案并未从主动成员中删除flex-active类。
I'll post the code as well for referense 我还将发布代码以供参考
$('.flexslider').flexslider({
animation: "slide",
directionNav: false,
controlNav: "thumbnails",
start: function(){
$('.flex-control-nav .flex-active').parent('li').addClass('flex-active').siblings().removeClass('flex-active');
},
after: function(){
$('.flex-control-nav .flex-active').parent('li').addClass('flex-active').siblings().removeClass('flex-active');
}
});
any help would be great! 任何帮助都会很棒!
I found this solution and its worked for me 我找到了这个解决方案,它为我工作
start: function() {
//-- Add flexslider active class to li of nav control instead of just on the image
if ($('.testimonial-section .flexslider ol.flex-control-nav').length > 0) {
// initial check and addition
$('.testimonial-section .flexslider ol.flex-control-nav li').each(function() {
if ($(this).children('img').hasClass('flex-active')) {
$(this).children('img').removeClass('flex-active');
$(this).addClass('flex-active');
} else {
$(this).removeClass('flex-active');
}
});
// bind into flexslider callback and run dynamically
$('.testimonial-section .flexslider').bind('start', function(event, slider) {
$('.testimonial-section .flexslider ol.flex-control-nav li').each(function() {
if ($(this).children('img').hasClass('flex-active')) {
$(this).children('img').removeClass('flex-active');
$(this).addClass('flex-active');
} else {
$(this).removeClass('flex-active');
}
});
});
}
},
after: function() {
//-- Add flexslider active class to li of nav control instead of just on the image
if ($('.testimonial-section .flexslider ol.flex-control-nav').length > 0) {
// initial check and addition
$('.testimonial-section .flexslider ol.flex-control-nav li').each(function() {
if ($(this).children('img').hasClass('flex-active')) {
$(this).children('img').removeClass('flex-active');
$(this).addClass('flex-active');
} else {
$(this).removeClass('flex-active');
}
});
// bind into flexslider callback and run dynamically
$('.testimonial-section .flexslider').bind('after', function(event, slider) {
$('.testimonial-section .flexslider ol.flex-control-nav li').each(function() {
if ($(this).children('img').hasClass('flex-active')) {
$(this).children('img').removeClass('flex-active');
$(this).addClass('flex-active');
} else {
$(this).removeClass('flex-active');
}
});
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.