Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDevin Watson
5,304 PointsAdding Class as the Element gets Activated
Hey there, I've just started using Animate.css. I'm trying to animate my paragraphs as I scroll. I thought I could do that by adding the animate class to the related paragraph as ScrollSpy is doing its thing and activating the current "li"s. But as you might have guessed, it doesnt work. I know that there would be some alternative way of doing it but I was wondering if I can achieve this with my way. So here's the related html and js/jquery (shortened):
<ul class="nav navbar-nav">
<li class="hidden">
<a href="#home"></a>
</li>
<li role="presentation">
<a href="#villa">OUR VILLA</a>
</li>
<li role="presentation">
<a href="#photos">PHOTOS</a>
</li>
<li role="presentation">
<a href="#reviews">REVIEWS</a>
</li>
<li role="presentation">
<a href="#contact">CONTACT US</a>
</li>
<li role="presentation">
<a href="#location">OUR LOCATION</a>
</li>
</ul>
<section id="villa">
<div>
<h2>Our Villa</h2>
<h4>Place you could call home</h4>
<p>A stylish townhouse, freshly redecorated. We can comfortably accomodate up to 6 guests with our 3 bedrooms and 2 bathrooms. We are located in the "golden mile" of exclusive Sandy Bay, only 5 minutes from the CBD and Salamanca. We provide bikes at no charge on site.</p>
</div>
</section><!-- END SECTION -->
var secId= $("section").attr("id"); // "villa"
var secHashId = "#" + secId; // "#villa"
function animateActive () {
if ( secHashId == $("li.active a").attr("href") ) {
$(secHashId).find("p").addClass("animate fadeInUp");
}
}
$(document).ready(animateActive);
Thanks in advance,
Ryan Zimmerman
3,854 PointsRyan Zimmerman
3,854 Pointsyou might want to look up .on http://api.jquery.com/on/