You can always just add to the queue
$.fn.hello = function() {
alert("hello world!");
return this;
}
$(document).delay(3000).queue(function() {
$(this).hello().dequeue();
});
FIDDLE
The reason it only works on animations, is because those are added to the FX queue automagically, but anything can be queued and dequeued in jQuery, you can even create your own custom queues that will work with delay()
For a custom queue you can do something like this
$({}).delay(3000, 'custom').queue('custom', function( next ) {
$(this).hello();
}).dequeue('custom');
FIDDLE
This is a little different, it's showing us that we can use an empty jQuery object as the holder and not just an element, and the second argument in delay()
is used to pass in the name of the queue, which we then attach and dequeue a little differently.
We're not really using the next
argument as there is nothing more in the queue to call, but it's an argument that you call to go the next step, as in you'd call next()
inside the function to proceed.