简体   繁体   中英

Show next Slide for current .flexslider only

I was hoping someone could help me modify the following piece of jQuery script to only go to the next slide for the object clicked and not all instances of .flexslider on my page

$(window).load(function() {
  $('[id^=flexslider_]').flexslider({
        animation: 'fade',
        slideshow: false,
        controlNav: false,
        directionNav : false,
        controlsContainer: '.flex-container',
        start: function(slider) {
          $('.slides li').click(function(event){
            event.preventDefault();
            slider.flexAnimate(slider.getTarget("next"));
         });
        }
   });         
 });

At the moment if i click any li element within .flexslider all my sliders change. I only want to select the slider i am clicking

EDIT

I have put in a

console.log(slider);

to see if it is finding each slider, the output is

div#flexslider_5.flexslider
div#flexslider_6.flexslider

So it has found both

Thanks

Small tweak to my existing setup has it working, thought i would post this incase it helps someone else

$(window).load(function() {
 $('[id^=flexslider_]').flexslider({
    animation: 'fade',
    slideshow: false,
    controlNav: false,
    directionNav : false,
    controlsContainer: '.flex-container',
    start: function(slider) {
     slider.find('.slides').click(function(event){ // Added slider.find('.slides')
        event.preventDefault();
        slider.flexAnimate(slider.getTarget("next"));
     });
    }
 });         
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM