根据父元素属性更改元素的CSS属性

问题描述 投票:0回答:2

我正在使用js-caurousal来改变工作正常的背景图像。除此之外,我还为每张幻灯片添加了标题,我使用animation.csswow.js以Fade效果制作动画。

问题是动画只播放一次,我想在幻灯片激活时播放标题文本的动画。我试图寻找解决方案,但我找不到多少。

所以我想从wow fadeIn类的元素中添加和删除slide-caption

以下是幻灯片的代码

<div class="js-carousel u-carousel-v5" data-autoplay="true" data-infinite="true" data-fade="true" data-speed="4000">
  <div class="js-slide g-bg-img-hero g-height-100vh--md g-min-height-300" aria-hidden="true" style="background-image: url(assets/img/1.jpg);">
    <h3 class="slide-caption wow fadeIn" data-animation="animated fadeIn" data-wow-delay="4s">Image One</h3>
  </div>

  <div class="js-slide g-bg-img-hero g-height-100vh--md g-min-height-300" aria-hidden="true" style="background-image: url(assets/img/2.jpg);">
    <h3 class="slide-caption wow fadeIn" data-animation="animated fadeIn" data-wow-delay="4s">Image Two</h3>
  </div>
</div>

如何使用以下$( ":hidden").attr( "aria-hidden", "true" )来添加和删除slide-caption中的css

javascript jquery css animation
2个回答
1
投票

我认为你应该使用它作为属性选择器,并做这样的事情:

$('div[aria-hidden=false] .slide-caption').removeClass('wow fadeIn');
.wow.fadeIn {
  color:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="js-carousel u-carousel-v5"
             data-autoplay="true"
             data-infinite="true"
             data-fade="true"
             data-speed="4000">
<div class="js-slide g-bg-img-hero g-height-100vh--md g-min-height-300" aria-hidden="true" style="background-image: url(assets/img/1.jpg);">
        <h3 class="slide-caption wow fadeIn"  data-animation="animated fadeIn"  data-wow-delay="4s" >Image One</h3>
    </div>

    <div class="js-slide g-bg-img-hero g-height-100vh--md g-min-height-300" aria-hidden="true" style="background-image: url(assets/img/2.jpg);">
        <h3 class="slide-caption wow fadeIn"  data-animation="animated fadeIn"  data-wow-delay="4s" >Image Two</h3>
    </div>
    
    <div class="js-slide g-bg-img-hero g-height-100vh--md g-min-height-300" aria-hidden="false" style="background-image: url(assets/img/2.jpg);">
        <h3 class="slide-caption wow fadeIn"  data-animation="animated fadeIn"  data-wow-delay="4s" >Image Three</h3>
    </div>
</div>

-1
投票

造型就像

.parentProperty1 .childClr {
     color: red;
}

.parentProperty2 .childClr {
     color: blue;
}
Your CSS Selector should be like
© www.soinside.com 2019 - 2024. All rights reserved.