I am trying to track the mouse position while you are clicking and dragging inside a div, and only while you are clicking and dragging. I used
$("div").mousedown(function() {
$("div").mousemove(function(event) {
$('div').html("( " + event.clientX + ", " + event.clientY + " )");
});
})
I have also tried
$("div").bind("mousedown mouseup", function () {
$("div").mousemove(function (event) {
$('div').html("( " + event.clientX + ", " + event.clientY + " )");
});
});
but they both keep tracking the mouse's position even after I let go of the mouse. How can I stop it after I stop clicking?
It's worth noting I have seen the answer from this questions, it won't work for me and I'm not sure why.