简体   繁体   English

带有滑动滑块的jQuery滑块

[英]Jquery slider with Slick slide

I am wanting to have multiple sliders inside of hquery tabs, the idea is that each tabs will be a category in Woocommerce but I am currently just hardcoding them in to initially get them to work. 我想在hquery选项卡中包含多个滑块,其想法是每个选项卡将成为Woocommerce中的一个类别,但是我目前只是对其进行硬编码以使其最初起作用。

The problem is when I move the slider html into the tab code the sliders no longer show? 问题是,当我将滑块HTML移到不再显示的标签代码中时,该滑块了吗?

Here is an exact replica of my issue: JSFIDDLE 这是我的问题的完整副本: JSFIDDLE

Once I understand and overcome this issue I am able to hen put in the loops I need. 一旦理解并克服了这个问题,我便可以将自己放入所需的循环中。

$('.tabs-nav a').on('click', function (event) {
    event.preventDefault();

    $('.tab-active').removeClass('tab-active');
    $(this).parent().addClass('tab-active');
    $('.tabs-stage div').hide();
    $($(this).attr('href')).show();
});

$('.tabs-nav a:first').trigger('click'); // Default


//////////////////////////////////////////////////////////////


$('.slider').slick({
  slidesToShow: 3,
  slidesToScroll: 1,
  autoplay: true,
  autoplaySpeed: 2000,
});

You made a mistake with your selector : $('.tabs-stage div').hide(); 您选择器出错: $('.tabs-stage div').hide(); This means hie every div inside '.tabs-stage' and his children so every div is hided, so when you show the active slider with $($(this).attr('href')).show(); 这意味着要hie every div inside '.tabs-stage' and his children每个div hie every div inside '.tabs-stage' and his children以便每个div被隐藏,因此当您使用$($(this).attr('href')).show();显示活动滑块时$($(this).attr('href')).show(); it only show the slider and not the div inside it who are still hidden. 它仅显示滑块,而不显示其中仍隐藏的div。

You should use : $('.tabs-stage > div').hide(); 您应该使用: $('.tabs-stage > div').hide(); (he > make all the difference) this way, it only hide the direct children off .tabs-stage . (他>使所有的差异)这样,它只是隐藏直接孩子关.tabs-stage

You FIDDLE edited 您FIDDLE已编辑

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

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