jQuery Document/Window Events

tutorial and example
tutorial and example

When the user resizes or scrolls the browser window then the events triggers. Here are some jQuery methods to handle the document/ window events:

1) The ready() Method

JQuery ready() method is used to specify when a ready event occur. Ready even occurs after the document is ready.

Syntax:

Example:


Try Now

2) The resize() Method

An event handler function is attached to an window element by the resize() method and that function is executed whenever the size of browser window changes.

Syntax:

Example:


Try Now

3) The scroll() Method

The scroll event of jQuery occurs when the user scrolls in the specified element and then the scroll() method triggers the scroll event, or attaches a function to run.

Example:


Try Now