To move a <div> from one location in your HTML to another using jQuery, you can use the detach() and append() methods. The detach() method removes the selected element from the DOM, while keeping all its data and event handlers intact. The append() method inserts the content specified into the specified element.
Here’s an example of how to do this:
jQuery('#source-div').detach().appendTo('#destination-div');
- The
#source-divelement is detached from the DOM. - The
#source-divelement is then appended to the#destination-divelement, effectively moving it.

0 Comments