How can I continuously get the position of the mouse whilst its button is being held down?
I know I can do:
<element onclick="functionName(event)"></element>
<script>
function functionName(e){
e.pageX
e.pageY
//do stuff
}
</script>
and I know you can use the onmousedown event, but how would I continuously get the position while the button is still held down?
Oddly I couldn’t find this anywhere I looked.
Anyway, I’d suggest using
mousemoveevent with check ifwhichevent property equals1(i.e. left mouse button pressed):DEMO: http://jsfiddle.net/HBZBQ/