javascript - how do I know if the mouse pointer is on the HTML element? -
I have an event at a time, I want to behave differently in that situation on which HTML element the mouse pointer is is.
There is a way, by thinking that I have an HTML element, to know that the mouse pointer is currently at the top of it.
I have good information about an on-home / on-house event and how to use them.
I am using JQuery
I am clearly looking for any type of flag because I do not have to check any state and handle any event.
Again, I know how to implement it with events.
To ping an element in the position of the mouse rotation, Not aware of the way.
However, you can create one by updating a flag in the mousecenter and mouseover - where the suggestions come:
jQuery.fn.tracking = function () { This .data ('hovering', false); This.hover (function () ($ (this) .data ('hovering', true);}, function () {$ (this) .data ('hovering', false);}); return;} ; JQuery.fn.hovering = function () {return.data ('hover');}
You will need to start tracking for each element that is noticeable:
$ ('# elem1, # elem2'). Tracking ();
But then you can get the status of any of them:
if ($ ('$ elem1') hovering ()) {// ...} and if ($ ('$ elephant') hovering ()) {// ...}
Demo:
Comments
Post a Comment