Swiper iDangero.us:特定幻灯片处于活动状态时的火灾事件

时间:2017-10-30 17:17:23

标签: javascript jquery slider swiper

当幻灯片2和4处于活动状态时,我试图隐藏某些div,但代码似乎无法正常工作。

要隐藏的元素:

<div id="element1">
   <h1 class="title">Title #1</h1>
</div>

<div id="element2">
    <h1 class="title">Title #2</h1>
</div>

Slider的代码:

<div class="swiper-container">
    <div class="swiper-wrapper">
        <div class="swiper-slide slide1"></div>
        <div class="swiper-slide slide2"></div>
        <div class="swiper-slide slide3"></div>
        <div class="swiper-slide slide4"></div>
    </div>
</div>

使用Javascript:

var swiper = new Swiper('.swiper-container', {
        ...,
        on: {
        init: function () {
        if (slideActiveClass.is('.slide2 .slide4')) {
        $(".title").addClass("hidden");
        } else {
        $(".title").removeClass("hidden");  
            }
          }
          }
    });

CSS:

.hidden {
    display: none;
    }

0 个答案:

没有答案