I’m using a global variable that toggles between true and false on mouse enter of a div and then I’m using the value of this variable elsewhere to show / hide another element depending on the value.
Actually, another way to do what I want would be to know if the mouse is hovering a div called MyDiv. I’m looking to remove the use of the global variable that toggles with the mouseenter/mouseleave events.
I tried this:
var test = $('#MyDiv').mouseover() ? 1 : 0;
but it’s not working.
Let me know if you have a 1-liner suggestion for returning the name of the div that’s being hovered.
Thanks.
PS: I already know it can be done with more than 1 line
You should store your flag in jQuery’s data storage: