If element has been 'mouseover'ed for 500ms, run function with jQuery
Posted
by PaulAdamDavis
on Stack Overflow
See other posts from Stack Overflow
or by PaulAdamDavis
Published on 2010-05-23T14:53:49Z
Indexed on
2010/05/23
15:00 UTC
Read the original article
Hit count: 157
For the sanity of my users, I want a 'mouseover' event to run after the selector has been hovered for half a second rather than as soon as they hover it.
I first tried a setTimeout function but that runs however long the element has been hovered, I didn't think it through too much I guess. I've also spent a day (on and off) searching (and playing Pacman) ti no result, unless I'm searching for the wrong things.
I would like to keep this plugin-less if we can, purely for run speed & maintainability.
$("#mySelector").mouseover(function(){
// Run after 500ms
$(this).addClass("hasBeen500ms");
});
Let's see if we can crack this, I know it will have so many applications!
© Stack Overflow or respective owner