Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery applying hover on pageload
    primarykey
    data
    text
    <pre><code>$("img").mouseenter(function(){ $(this).addClass("move"); }); </code></pre> <p>The situation is this: When you hover <code>img</code> a <code>.move</code> class is added to it (i.e. becoming <code>img.move</code> when hovered). This might be confusing to explain, but the problem is I need <code>.move</code> class to be added only if the <code>img</code> isn't already hovered on pageload.</p> <p>To illustrate, let's pretend my site has a logo <code>img</code> that appears in the same spot on every page.</p> <p>If a user hovers the logo, <code>.move</code> class is added to it (making the logo "move" around with css) Now the user clicks on the logo loading the homepage, but if their mouse is still on the logo when the new page loads, <code>.move</code> class is added making the logo move around again. I don't want the logo to "move around" if their mouse is already on the logo when the page loads. It should only "move around" if they hover the logo from somewhere else on the page.</p> <p><strong>I need this:</strong></p> <blockquote> <p>(page loads) > (mouse is not hovered on <code>img</code>) > (then if mouse hovers <code>img</code>) > (add <code>.move</code> class to <code>img</code>)</p> </blockquote> <p><strong>But get rid of this:</strong></p> <blockquote> <p>(page loads) > (mouse is already hovered on <code>img</code>) > <strong>!!!(add <code>.move</code> class to <code>img</code>)!!! &lt;-- Don't add <code>.move</code> if the mouse is already on the <code>img</code></strong></p> </blockquote> <p>What's the best way to do this with jQuery?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload