<div class="drag"></div> <script type="text/javascript"> $(".drag").mousedown(function(e){ var x1=e.clientX-$(".drag").offset().left; var y1=e.clientY-$(".drag").offset().top; $(document).bind("selectstart",function(){return false;}); $(document).mousemove(function(e){ var x2=e.clientX-x1; var y2=e.clientY-y1; $(".drag").css({left:x2,top:y2}); }) }) $(document).mouseup(function(){ $(document).unbind('selectstart'); $(document).unbind('mousemove'); }) </script>