Hey guys, I have written this code from the ground up using jQuery (first real jQuery project), and so far, I have some toggle animation. My code looks like this:
HTML
<div id="content">
<div class="featured-img one">
<img src="media/desktopography.png" alt="Desktopography"/>
</div><!-- end .featured-img -->
<div class="featured-img two">
<img src="media/dancer.png" alt="Dancer"/>
</div><!-- end .featured-img -->
<div class="featured-img three">
<img src="media/tech.png" alt="Tech"/>
</div><!-- end .featured-img -->
<div class="featured-img four">
<img src="media/strawberry-tree.png" alt="Strawberry Tree"/>
</div><!-- end .featured-img -->
<div class="featured-img five">
<img src="media/snow-leopard.png" alt="Snow Leopard"/>
</div><!-- end .featured-img -->
</div><!-- end #content -->
jQuery
$(document).ready(function(){
$('.featured-img').toggle(
function() {
$(this).animate({
height: "600px",
marginTop: "-100px"
}, 500 );
$(".featured-img > img").animate({
marginTop: "0px"
}, 500 );
},
function() {
$(this).animate({
height: "150px",
marginTop: "100px"
}, 1500 );
$(".featured-img > img").animate({
marginTop: "-200px"
}, 1500 );
}
);
});
This works fine with one element, BUT it applies the same animation to every element assigned .featured-img on each click. Is there any way I can only animate the element I clicked, without disturbing the other ones at all?
I have tried playing with :not(:animated), and other stuff, but it only made it worse. I would appreciate any help or suggestions.
Thanks in advance!