jQuery Resize Event

The resize event runs when the browser viewport changes size. Attach it to window.

Syntax Top ↑

$( window ).on( "resize", function () {
    // The viewport size changed.
});

Display the Current Window Width Top ↑

$( function () {
    $( window ).on( "resize", function () {
        $( "#d1" ).text(
            "Window width: " + $( window ).width() + " px"
        );
    });
});

Example HTML Top ↑

<div id="d1">Resize this browser window.</div>

Resize handlers can fire frequently. For expensive work, consider debouncing the handler so layout calculations do not run on every intermediate resize event.

Window Events with jQuery






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer