cut completely and paste an element

Can I cut (completely, with all styles and attributes) an element from a location and paste it in another location (like body) with jQuery?

Also, I want to place a string (or tag) in the old location, because I want to change its place to old location at the end of the script.

Can I? How?

Thank you.


appendTo() will automatically move the matched elements from their current location to the specified container, which seems to be what you want.

You can use after() to insert new content before moving the element:

$("#yourElement").after("<p>Element was there</p>").appendTo("body");