dude
dude

Reputation: 4972

Jquery drag and drop ?How to make the drag div fixed

Link to the code -JS FIDDLE LINK

var makeDrag = function(){
    $("#hello").draggable({
        stop: function(){
            alert("Done dragging");

            $("#hello").draggable("destroy");

            var copy = $("#hello").clone(true);
            $("body").append(copy);
            copy.html("DRAG");
            copy.draggable();
            copy.css("left","120px");
            copy.css("top","140px");

            makeDrag();
        }
    });
}

makeDrag();

<div id="hello">DRAG</div>//THIS DIV SHOULD BE FIXED IN THE SAME POSITION 

I am able to drag and drop but i the div hello to be fixed ? how to achieve this? For eg EXAMPLE LINK

Upvotes: 0

Views: 795

Answers (1)

Kundan Singh Chouhan
Kundan Singh Chouhan

Reputation: 14292

Use helper: "clone" option.

$("#hello").draggable({
    helper: "clone",
    stop: function(){ 
      //existing stuff
    }
});

Working Demo

Upvotes: 1

Related Questions