I integrate flexslider into the site. http://flexslider.woothemes.com/index.html
Now I want to add a class before and after the current slide. Each time the current slide changes, the classes will be updated. I managed to do this with the following jquery:
setInterval(checkCurrent, 100);
function checkCurrent(){
$('.gallery #slider li').removeClass('beforeCurrent afterCurrent');
var current = $('.gallery #slider li.flex-active-slide');
current.prev().addClass('beforeCurrent');
current.next().addClass('afterCurrent');
}
However, in this way, it will run a function every 100 milliseconds, which I find less reasonable. I do not intend to use any flexslider function, since I need to use it in another slider plugin in the future. I need a pure jquery solution. Any suggestion?
source
share