Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  56] [ 6]  / answers: 1 / hits: 59709  / 13 Years ago, thu, august 25, 2011, 12:00:00

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?


More From » jquery

 Answers
2

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);

[#90425] Wednesday, August 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ervindouglasm

Total Points: 451
Total Questions: 103
Total Answers: 102

Location: Turkmenistan
Member since Thu, Dec 1, 2022
2 Years ago
;