English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery resize() Method

jQuery Events

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

The resize event occurs when the document view (browser window) changes its size.

Syntax:

Trigger the resize event of the selected element:

$.resize()

Attach a function to the resize event:

$.resize(function)

Example

Calculate the number of times the browser window is resized:

$(window).resize(function() { 
  $("span").text(x++); 
});
Test and see‹/›

Display the window width when resizing (or after):

$(window).resize(function() { 
  $("span").text($(this).width());
});
Test and see‹/›

Parameter Value

ParametersDescription
functionFunction executed each time the resize event is triggered

jQuery Events