Skip to content

Instantly share code, notes, and snippets.

@scruffyfox
Created November 13, 2011 19:45
Show Gist options
  • Save scruffyfox/1362570 to your computer and use it in GitHub Desktop.
Save scruffyfox/1362570 to your computer and use it in GitHub Desktop.
JQuery Delay
//********************************************************************
//
// jQuery delay created by Callum Taylor
// v 0.1
// This simple function is to emulate a javascript setTimeout but
// in a jQuery way. This is not the same as the standard effects delay
// where you can only use delay AFTER an effect, this plugin can
// be used on its own to delay a function from executing
//
// Usage:
// @delay: time in Milliseconds
// @Callback: nested function or funtion name
// $.delay(delay, callback);
//
//********************************************************************
$.delay = function(timeout, callback)
{
$('body').append("<a id='jqdelay'></a>");
$('#jqdelay').animate(
{
"delay": 1
}, timeout, callback);
$('#jqdelay').remove();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment