Search code examples
jqueryclone

jQuery: add clone to container


Is there other ways to add a cloned element to an container than:

$(".product").draggable({
    helper: 'clone'
});

$("#container").append(ui.draggable.clone());

append just puts the element after the last element in #container. I want to decide where the position should be.


Solution

  • You can use before() or after() to insert an element at a specific position.

    $(".product").draggable({
        helper: 'clone'
    });
    
    $("#container #target").after(ui.draggable.clone());