You can use the jQuery clone()
method to clone the main draggable element and then initialize the cloned version as draggable using the jQuery UI draggable()
method as follows:
// Clone the main draggable element
var $clonedElement = $('#main-draggable').clone();
// Make the cloned element draggable
$clonedElement.draggable();
// Append the cloned element to the container
$('#container').append($clonedElement);
Note that you should give the cloned element a new ID or class, otherwise you'll end up with multiple elements with the same ID, which is invalid HTML.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-05 11:00:00 +0000
Seen: 12 times
Last updated: Sep 29 '22
Why is it that the Jquery click event is not functioning on newly inserted elements?
Is it not possible to clone a repository using Git on PyCharm?
What is the process for making a react project with a cloned create-react-app?
How to give an <svg> element a double border using CSS when there is no style attribute present?
Why does the fixed position interfere with the functionality of overflow hidden?