My code is`
<script>
$(function(){
var xco,yco,sen,ple,pto;
document.onmouseup=function(){document.onmousemove=null;};
$(".pcre").mousedown(function(e){sen=$(this);
ple=sen.offset().left;
pto=sen.offset().top;
xco=e.clientX;
yco=e.clientY;
$(document).mousemove(function(e){fle=ple+e.clientX-xco;
fto=pto+e.clientY-yco;
sen.css("top",fto);
sen.css("left",fle);
});
});
});</script>
`When I move the div it moves but on mouseup nothing happens and it keeps on following mouse
I suggest you using the jQuery UI: http://jqueryui.com/
It’s like a plugin for jQuery providing tools for animations, user interactions and much more.
Example for a draggable DIV: http://jsfiddle.net/TFjB7/
You see, it’s really easy:
$('.draggable').draggable();You can find more examples and the documentation on http://jqueryui.com/demos/draggable/ . Just download it and include it in your document.