.resize()


.resize( handler )Возвращает: jQuery

Описание: Устанавливает обработчик изменения размеров окна браузера, либо, запускает это событие.

  • Добавлен в версии: 1.0.resize( handler )

    • handler
      Тип: Function( Event eventObject )
      A function to execute each time the event is triggered.
  • Добавлен в версии: 1.4.3.resize( [eventData ], handler )

    • eventData
      Тип: Anything
      An object containing data that will be passed to the event handler.
    • handler
      Тип: Function( Event eventObject )
      A function to execute each time the event is triggered.
  • Добавлен в версии: 1.0.resize()

    • This signature does not accept any arguments.

This method is a shortcut for .on('resize', handler) in the first and second variations, and .trigger( "resize" ) in the third.

The resize event is sent to the window element when the size of the browser window changes:

1
2
3
$( window ).resize(function() {
$( "#log" ).append( "<div>Handler for .resize() called.</div>" );
});

Now whenever the browser window's size is changed, the message is appended to <div id="log"> one or more times, depending on the browser.

Code in a resize handler should never rely on the number of times the handler is called. Depending on implementation, resize events can be sent continuously as the resizing is in progress (the typical behavior in Internet Explorer and WebKit-based browsers such as Safari and Chrome), or only once at the end of the resize operation (the typical behavior in some other browsers such as Opera).

Дополнительные замечания:

  • As the .resize() method is just a shorthand for .on( "resize", handler ), detaching is possible using .off( "resize" ).

Примеры использования