Reputation: 230
I'm running into a snag on a simple .hasClass
.addClass
concept. I have a full page layout that matches my media devices viewport. When you scroll or click on the nav it jumps to the next corresponding div by way of the transference of a active
class.
What I'm hoping to do is addClass
to the active
divs img inside it to apply an animation into the page. For some reason though, this is just not working out for me. As the active
class transfers the img doesn't update with it.
Thoughts?
if ( $('.section').hasClass('active') ) {
$('.active img').addClass('slideUp');
}
.section { min-height: 200px; background:rgba(0,0,0,0.15); padding: 15px; }
.active img { background:rgba(0,0,0,1);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section active" id="section0">
<img src="http://www.smashbros.com/images/character/kirby/main.png">
</div>
<div class="section" id="section1">
<img src="https://kirby.nintendo.com/planet-robobot/assets/img/home/copy-kirby.png">
</div>
Upvotes: 0
Views: 79
Reputation: 3435
From your last comment, just add the slideUp class at the same time as you add the active class (basically on the click listener for the nav)
Upvotes: 1