Reputation: 933
I can get the coordinates within $(document).ready(function() { $(id).mouemove(function(){}) };
But what if I want to get the coordinates right in a function?
<div id='abc' onmouseover="callFunction(this.id)"></div>
I only get undefined. Why?
function callFunction(arg){
mouseX = arg.pageX;
mouseY = arg.pageY;
alert('--> ' + mouseX + ' - ' + mouseY);
}
Upvotes: 0
Views: 3716
Reputation: 694
<div id='abc' onmouseover="callFunction(event)">123</div>
function callFunction(e){
console.log(e);
mouseX = e.clientX;
mouseY = e.clientY;
alert('--> ' + mouseX + ' - ' + mouseY);
}
Upvotes: 3