Edit in JSFiddle

$(document).ready(function () {
    $('#drag').mousedown(function(){
        $(document).mousemove(function(event){
            $('#drag').css({'left':event.pageX,'top':event.pageY});
            
        });
    });
    $(document).mouseup(function(){
        $(this).off('mousemove');
        $('#drag').css({'left':'','top':''})
    });  
});

<body>

    <div id="drag">

    </div>
    


</body>
    #drag {
        width: 20px;
        height: 20px;
        border-radius:10px;
        background: #ccc;
        position: fixed;
    }

External resources loaded into this fiddle: