Is it possible to get the current element using mousemove ? I'd like to get the element where the mouse is to do specifics things if the mouse isn't on an element x or y.
For exemple :
$(document).mousemove(function(e)
{
if(e.xxxx.attr("id") == "elem")
...
});
xxxx is what I'm looking for, and I hope it exists :)
Thanks
If you mean the element the mouse is over, yes, it's available as the target
property of the event object.
$(document).mousemove(function(e)
{
if (e.target.id == "elem") {
// ...
}
});
target
is a DOM element, and you can access the id
of the element directly from its id
property (a reflected property that takes its value from the attribute). If you wanted to do other things with it and wanted access to the jQuery functions, you'd use $(e.target)
to get a jQuery wrapper for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With