Skip to content
Related Articles
Open in App
Not now

Related Articles

What is the use of delay() method in jQuery ?

Improve Article
Save Article
  • Last Updated : 28 Sep, 2021
Improve Article
Save Article

In this article, we will see how to use delay() method and why to use it in jQuery. The delay() method is used to set a timer to delay the execution of the next item in the queue.


$(selector).delay(para1, para2);

In the below example, first we create a div of size 250px X 200px and set its display property to none. Also, created a button that will call delay() method. When user click on button, the delay() method and fadeIn() method called. The delay() method take 2000ms value it means the div will display after 2000ms.  



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <!-- Including jQuery -->
    <script src="
        div {
            width: 250px;
            height: 200px;
            display: none;
            background-color: green;
        <h1 style="color: green;">
            What is the use of delay() 
            method in jQuery?
        <button id="delay">delay() method</button>
        $(document).ready(function() {
            $('#delay').click(function() {


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!