Reputation: 3017
I call this function I have getMouseXY, whenever the mouse moves. Works great for tracking this element with the mouse. Like so:
document.onmousemove = getMouseXY;
But I'd like to layer in some logic, so it's only when the mouse is over this one element AND the mouse is moving. I thought this would work, but it doesn't:
document.getElementById("circle1").onmouseover && document.onmousemove = getMouseXY;
Any ideas? Help is much appreciated!
Upvotes: 1
Views: 37
Reputation: 318302
You're probably looking for
document.getElementById("circle1").addEventListener('mousemove', getMouseXY);
which will fire whenever the mouse moves over the element with the ID #circle1
Upvotes: 2