Simple question, how would I accomplish this functionality in Jquery:
Test whether the mouse is hovering over .myBox
if ($(".myBox").mouseleave = true) {
DO SOMETHING
} else {something else}
OR
if ($(".myBox").mouseover = false) {
DO SOMETHING
} else {Something else}
NOTE: im looking for an IF statement
jQuery provides the is
method for checking conditions with regard to a jQuery object. In your case you can check for the :hover
CSS pseudo class:
$('.myBox').is(':hover') === true
Havre a look at this demo, try clicking the button (which will alert true
) and the tabbing to and hitting enter on the button (without the mouse, it will return false
).