Search code examples
javascriptjquerydelaymouseenter

jQuery: Delay a mouseenter event (dropdown menu)


I'm working on this fiddle: http://jsfiddle.net/8n2TQ/9/

It consists of a rollover button which drops down a menu like so:

$('#one').mouseenter(function() {

    //Slide down

});

The event happens immediately on hover, but I want to put in a small delay to prevent accidental hovers from triggering the event. I tried to work with a timer (see http://jsfiddle.net/8n2TQ/13/) but that doesn't seem to execute all the events under '//Slide up'. I guess I'm missing something here, what am I doing wrong?


Solution

  • https://github.com/briancherne/jquery-hoverIntent

    There is a plugin for this that works well.