Trigger Events After A Delay - jQuery onDelay

File Size: 4 KB
Views Total: 1246
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Trigger Events After A Delay - jQuery onDelay

An alternative to the jQuery on() method that enables you to fire events after an interval of time you specify, similar to the native JavaScript setInterval() method.

See Also:

How to use it:

1. Install the plugin by inserting the JavaScript file onDelay.min.js after jQuery.

<script src="" 
<script src="onDelay.min.js"></script>

2. Use the plugin to output what you typed in a textarea after 3 seconds.

<div class="alert">You Just Typed: </div>
  jQuery('textarea').onDelay('input', function() {
    $( ".alert" ).append( this.value );
  }, 3000);

3. All possible parameters:

  • events: One or more space-separated event types and optional namespaces.
  • selector: A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
  • data: Data to be passed to the handler in when an event is triggered.
  • handler: A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
  • delay: Delay in milliseconds.
jQuery.onDelay( events [, selector ] [, data ], handler, delay )

This awesome jQuery plugin is developed by knickers. For more Advanced Usages, please check the demo page or visit the official website.