Easy Tutorial
❮ Sel Attribute Notequal Value Sel Multiple Elements ❯

jQuery ready() Method

jQuery Event Methods

Example

Use ready() to make a function available after the document has loaded:

$(document).ready(function(){
    $("button").click(function(){
        $("p").slideToggle();
    });
});

Definition and Usage

The ready event occurs when the DOM (Document Object Model) is fully loaded and the page is completely loaded (including images).

Since this event occurs after the document is ready, it is a good practice to place all other jQuery events and functions within it, as shown in the example above.

The ready() method specifies the code to be executed when the ready event occurs.

Tip: The ready() method should not be used with <body onload="">.


Syntax

The following syntaxes are allowed:

The ready() method is only applicable to the current document, so no selector is needed:

Parameter Description
function Required. Specifies the function to run after the document has loaded.

jQuery Event Methods

❮ Sel Attribute Notequal Value Sel Multiple Elements ❯