$target.remove()
can remove the element,but now I want the process to be down with some feel animation,how to do it?
views:
486answers:
5
+3
A:
target.fadeOut(300, function(){ $(this).remove();});
or
$('#target_id').fadeOut(300, function(){ $(this).remove();});
Duplicate: http://stackoverflow.com/questions/553402/jquery-fadeout-remove
micahwittman
2009-11-27 07:06:56
+4
A:
$target.hide('slow');
or
$target.hide('slow', function(){ $target.remove(); });
to run the animation, then remove it from DOM
edit: not sure why I'm getting voted down for this...
Greg
2009-11-27 07:09:39
This won't remove the element from the DOM. It only hides the element.
rahul
2009-11-27 07:10:41
I need it to be exactly removed.I tried $target.hide('slow').remove() but not working。
Mask
2009-11-27 07:11:55
In that case: $target.hide('slow', function(){ $target.remove(); });
Greg
2009-11-27 07:12:50
@Mask -- you need to chain that. It removes it as soon as it starts the animation, so you have to put the remove in the callback
Greg
2009-11-27 07:14:12
Yup,works now,ty!
Mask
2009-11-27 07:16:06
The .remove() method very specifically removes the node from the DOM. The .hide() method only changes the display attribute to make is not visible, but still in existence.
micahwittman
2009-11-27 07:19:34
@Greg,+1 for it works:)
Mask
2009-11-27 07:27:35
A:
If you need to hide and then remove the element use the remove method inside the callback function of hide method.
This should work
$target.hide("slow", function(){ $(this).remove(); })
rahul
2009-11-27 07:13:04