Check if mouse is hovering over an element

The simplest solution to check if the mouse is hovering over an element or a child of an element using jQuery.


Libraries

Code Snippet
if ($('#element:hover').length != 0) {
    // mouse is over
}


Implementation

Use the statement above to check if the mouse is over the element with id "element".





Comments
  • mode_editWrite a comment



  • forumComments




Embed Code

We provide special containers which include the full snippet and a link to this site. So for example when you make a tutorial and you are using code from this site, you can use one of the following snippet embeddings:

Load Preview Get Code Close Preview







    Share
    Rating
    thumb_up 0 thumb_down
    Author
    Thorolus

    I'm the head developer and co-founder of GlovilGames Studios (glovilgames.com) and other platforms GlovilGames created, like vsnippets.com, worth-calculator.net, python-obfuscator.com and some mobile apps and games.

    Tags
    Event
    Mouse
    DOM



    Informations

    posted on 2016-09-21 20:46:11

    viewed 131 times

    snippet's UUID is 57e2d57310981

    Similar Snippets