首页 文章

旋转木马导航每个功能

提问于
浏览
1

我有一个页面使用多个轮播(猫头鹰旋转木马),每个都有一个导航,如prev / next . 其中一些没有足够的物品可以考虑作为旋转木马,所以我想禁用这个导航 . 结构看起来:

<div class="videos-wrap">
<div class="owlnav owlnav1"><div class="owl-prev" style="">&lt;</div><div class="owl-next" style="">&gt;</div></div>
    <div class="video-carousel"></div>
    <div class="video-carousel"></div>
    <div class="video-carousel"></div>
</div>

<div class="videos-wrap">
<div class="owlnav owlnav1"><div class="owl-prev" style="">&lt;</div><div class="owl-next" style="">&gt;</div></div>
    <div class="video-carousel"></div>
</div>

...

我试着做几件事,比如

$(".videos-wrap").each(function() {
var n = $( ".video-carousel" ).length;  
if (n < 3) {
    $('this .owlnav').css('display', 'none');
}

});

但不工作

有任何想法吗 ?

谢谢你的帮助

1 回答

  • 0

    你走在正确的轨道上 . 试试这个:

    $(".videos-wrap").each(function() {
        var n = $(this).find(".video-carousel").length;
        if (n < 3) {
            $('.owlnav', this).css('display', 'none');
        }
    });
    

    这些更改只是使用类 .video-carousel 找到当前 .videos-wrap 的子项 . 然后我对改变显示的选择器做了一点改动 .

    现场观看:http://jsfiddle.net/g6d39b04/

相关问题