Here is an example fiddle were you click on the red box and it shows the coordinates of your pointer relative to the box.
How am I able to modify this script to allow the coordinates to update if I click and drag? Allowing the coordinates to update live as I am holding down the click and moving the mouse.
http://jsfiddle.net/lonesomeday/5qxtL/2/
Code from Fiddle:
$('#target').mousedown(function(e) {
var offset = $(this).offset(),
imgLeft = e.pageX - offset.left,
imgTop = e.pageY - offset.top;
$('#result').text('Mouse clicked x = ' + imgLeft + ' Y = ' + imgTop);
});
I've tried a few different things but nothing has worked so far and can't find another question that's similar apart from one without an answer.
Thanks