简体   繁体   English

单击flexslider中的图像时如何显示下一张幻灯片

[英]How to show the next slide when you click on the image in flexslider

I'm using the flexslider plugin and i wanted to know if there is an easy way (apart from changing the core of the plugin which is what i am going to do if i don't find an easy answer) to show the next slide when you click on the current slide. 我正在使用flexslider插件,我想知道是否有一个简单的方法(除了更改插件的核心,这是我将要做的,如果我没有找到一个简单的答案)显示下一张幻灯片当您单击当前幻灯片时。 I set up the flexslider like this 我像这样设置了flexslider

$('.flexslider').flexslider({
    directionNav : false,
    slideshow: false,
        animation: "slide",
        controlsContainer: ".flex-container"
    });

I disabled the Prev/Next command because i didn't like them. 我禁用了Prev / Next命令,因为我不喜欢它们。 What should i do? 我该怎么办?

Maybe a little bit too late, but here's the solution for Flexslider 2: 也许有点太晚了,但这是Flexslider 2的解决方案:

$('.flexslider').flexslider({
    directionNav : false,
    slideshow: false,
    animation: "slide",
    controlsContainer: ".flex-container",
    start: function(slider) {
    $('.slides li img').click(function(event){
        event.preventDefault();
        slider.flexAnimate(slider.getTarget("next"));
    });
}
});

I had a Safari problem with the code above. 我上面的代码遇到了Safari问题。 This is my easy solution. 这是我的简单解决方案。

jQuery( document ).ready( function( $ ) {
    $('.flexslider').on('click', function(){
        $(this).find('.flex-next').click();
    });  
}


$(window).load(function() { 
    // Slider
    $('.flexslider').flexslider({
    directionNav : false,
    slideshow: false,
    animation: "slide",
    controlsContainer: ".flex-container"    
    });
});

Here's a small update to the accepted answer above that targets the specific slider clicked, rather than all the sliders on the page: 以上是对上面接受的答案的一个小更新,它针对的是点击的特定滑块,而不是页面上的所有滑块:

$('.flexslider').flexslider({ 
    start: function(slider) {
        $('.slides li img', slider).click(function(event){
            event.preventDefault();
            slider.flexAnimate(slider.getTarget("next"));
        });
    }
});

After each slider animation completes, find the active slide and change the image src 每个滑块动画完成后,找到活动幻灯片并更改图像src

$('.flexslider').flexslider({
    animation: "slide",
    animationLoop: false,
    slideshow: false,
    touch: true,
    itemWidth: 235,
    itemMargin: 10,
    after: function (slider) {
      $(slider).find('.flex-active-slide').find("img").each(function () {
      var src = $(this).attr("data-src");
      $(this).attr("src", src).removeAttr("data-src");
   });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flexslider-单击图像前进到下一张幻灯片 - Flexslider - click image to advance to next slide 只显示当前.flexslider的下一张幻灯片 - Show next Slide for current .flexslider only 如何在flexslider的每个幻灯片中显示6张图像? - How to show 6 images in each slide of flexslider? Flexslider:在自定义按钮单击时移动到下一张幻灯片(有延迟) - Flexslider: move to next slide (with a delay) on custom button click flexslider如何在单击背景时显示我的照片灯箱 - flexslider How to show my photo lightbox when i click background 当有人使用jQuery单击子导航项时,如何在Flexslider中显示特定幻灯片? - How do i show a specific slide in Flexslider when someone clicked on sub nav item using jQuery? 单击图像时,使文本显示(向上滑动) - Make Text appears (Slide up) under an Image when you click on it 当您单击下一张图片时,如何将回调(cufon)应用于Galleria jquery插件 - How do you apply a callback (cufon) to the Galleria jquery plugin when you click on next image 下一张幻灯片进来时,如何停止幻灯片放映隐藏文字和图像跳到顶部? - How to stop slide show hide text and image jumping on top while next slide come in? 如何在幻灯片切换中首先隐藏 div 并在单击时显示? - How to hide div first in slide toggle and show when click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM