Reputation: 1916
I have a list of elements with a remove button on each element, I'm trying to make the remove button fadeOut the element while the siblings move to top. The problem is that when I click on remove the elemenent in question fades out but the siblings don't move, they just change position without animation. How can I make them move up while the element above is fading out. Here's the jsfiddle: http://jsfiddle.net/4c82H/
Here's the code:
$('div').click(function() {
$element = $(this);
var height = $element.height();
$element.fadeOut(400);
$element.next().animate({top:'-=' + height + 'px'});
});
Thank you!
EDIT: Some are proposing slideUp, thank you for this, it works, but is there a way to fade the element while others are sliding?
$element.fadeOut();
$element.slideUp();
Does not work.
Upvotes: 0
Views: 469
Reputation: 74420
As suggested by Neta, you should use slideUp() instead:
$('div').click(function() {
$(this).slideUp();
});
Upvotes: 1
Reputation: 3656
slideUp
will do it. I've attached a sample here. http://jsfiddle.net/4c82H/1/
Upvotes: 4