jQuery Event - resize() Method

Example

Count the resize of the browser window:

$$(window).resize(function() {
  $('span').text(x+=1);
});

Try It Yourself

Definition and Usage

The resize event occurs when the browser window size is adjusted.

The resize() method triggers the resize event or specifies a function to be executed when the resize event occurs.

Triggers the resize event

Syntax

$(selector).resize()

Try It Yourself

Binds a function to the resize event

Syntax

$(selector).resize(function)
Parameters Description
function Optional. Specifies a function to be executed when the resize event occurs.

Try It Yourself