Reputation: 5413
I was testing out an approach to a solution and found that the methods or functions available for a programmatically triggered JavaScript event is different from ones that are available when the user clicks on the element. For instance, I wasn't able to get the mouse positions of the click event. If the user had clicked, I would have been able to get the mouse positions and a lot more. I am adding the events and triggering it via jQuery. Any reason for this? Any one know how I can get the mouse position after programmatically triggering it using jQuery?
Upvotes: 0
Views: 111
Reputation: 3449
you can use the offset jquery function:
var clickedPostion = $(this).offset();
alert(e.clientX - clickedPostion.left);
alert(e.clientY - clickedPostion.top);
I know the sample it is on click, but you can change it to mousemove()
Here is a working sample:
Upvotes: 3