animate() and closest() + filter() or callback
Hi there.
I want to animate ALL classes called ".article" to opacity=.2 and then fire a callback, which animates ONLY the closest ".article" to ".button" back to opacity=1.
Know, what i mean?
Here's the script:
-
$('.button').click(function() {
$('.article').animate({
opacity: '.2'
}, 300, function callback() {
$(this).closest('.article').animate({
opacity: '1'
}, 300 );
});
});
What it does:
it animates ALL ".article" classes to opacity=.2 but then the callback animates again ALL ".article" to opacity=1 and NOT ONLY the closest.
What's wrong?
Besides that i could imagine not to use a callback but use a filter instead, which filters the closest ".article" out and keeps its opacity as it is.
But i really don't know how to combine filter() closest() and animate()
Please! Help is very much apreciated!
Thanks in advance,
s.