105
rated 0 times
[
112]
[
7]
/ answers: 1 / hits: 107705
/ 12 Years ago, sun, february 10, 2013, 12:00:00
I have seen this jQuery syntax:
if($(element).is(':hover')) { do something}
Since I am not using jQuery, I am looking for the best way to do this in pure javascript.
I know I could keep a global variable and set/unset it using mouseover
and mouseout
, but I'm wondering if there is some way to inspect the element's native properties via the DOM instead? Maybe something like this:
if(element.style.className.hovered === true) {do something}
Also, it must be cross browser compatible.
More From » jquery