Just add e.preventDefault()
to your mousedown handler, like this:
var target = $('img')
var pos = 0;
var dragging = false;
$(document).mousedown(function(e) { e.preventDefault(); pos=e.pageX; dragging = true })
$(document).mouseup(function() { dragging = false })
$(document).mousemove(function(e) {
if(dragging){
target.css('left', e.pageX-pos);
}
})
See working demo .
The rationale for the fix is, that the browser was also doing his own native image drag-and-drop (like when eg. you drag an image out of the browser to drop it in an external application) so you need to cancel that default native drag-and-drop with .preventDefault()
.