I’m trying to track the mouse position while I click and drag an a[href] value to the bookmarks bar (it’s for a bookmarklet). It seems to stop tracking a few seconds after I start dragging.
Code is below.
var isDragging = false;
$('a#dragthis')
.mousedown(function() {
$(window).mousemove(function(e) {
isDragging = true;
var x = e.pageX;
var y = e.pageY;
console.log(x + "|" + y);
});
});
Here is a jsFiddle example: http://jsfiddle.net/GZpHP/
You need to
return falsein yourmousedownhandler, to prevent the default action of selecting text upon drag.Updated fiddle