mouseover with delay (using hoverIntent plugin)

hoverIntent is a plug-in that attempts to determine the user’s intent… like a crystal ball, only with mouse movement! It works like (and was derived from) jQuery’s built-in hover. However, instead of immediately calling the onMouseOver function, it waits until the user’s mouse slows down enough before making the call.
Continue reading “mouseover with delay (using hoverIntent plugin)”

keyup function with delay

 

This code will execute a function after the user has stopped typing for a time of 1000ms. Hence the function will not be called on each keyup event. Great!!!

jQuery(function(){
    var delay = (function(){
        var timer = 0;
        return function(callback, ms){
            clearTimeout (timer);
            timer = setTimeout(callback, ms);
        };
    })();

    $('input').keyup(function() {
        delay(function(){
            alert('Time elapsed!');
        }, 1000 );
    });

});