13

Can I get cursor position at mousedown(event) event, without using mousemove(event) continuously (thus waisting resources)? event.pageX returns NaN on mousedown

6
  • 3
    It which browser? It's fine for me in Chrome and Firefox: jsfiddle.net/interdream/JsaPG/3 Commented Aug 5, 2011 at 7:21
  • @James: works, bug in my code, sorry for troubling : )
    – Jakub M.
    Commented Aug 5, 2011 at 7:24
  • No problem, I thought that might be the case! Commented Aug 5, 2011 at 7:26
  • @Jakub, can you provide an answer? then others can learn from your mistake. This isn't just a Q&A site, but also a reference of sorts :) Commented Aug 5, 2011 at 7:30
  • 1
    @Jakub - My "answer" isn't really an answer (which is why I posted it as a comment). It would probably be more helpful to other users who come across this page if you post a description of what the problem was and how you fixed it. You can post it as an answer to your own question. Commented Aug 5, 2011 at 7:43

1 Answer 1

16

On behalf of James:

from - http://jsfiddle.net/interdream/JsaPG/3/

<input type="button" id="test" value="click" style="width:200px" />

$("#test").mousedown(function(e) {
   console.log(e.pageX); 
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.