Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

jQuery | resize() with Examples

  • Last Updated : 13 Feb, 2019

The resize() method is an inbuilt method in jQuery which is used when the browser window change its size.


Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!


Parameter: This method accepts single parameter function which is optional. It is used to specify the function to run when the resize event is called.

Return Value: This method returns the selected element with increases its size.

Below example illustrates the resize() method in jQuery:


<!DOCTYPE html>
        <title>The resize method</title>
        <script src=
        <!-- jQuery code to show the working of this method -->
            x = 0;
            $(document).ready(function() {
                $(window).resize(function() {
                    $("p").text(x += 1);
            div {
                width: 150px;
                height: 100px;
                padding: 20px;
                border: 2px solid green;
                font-size: 20px;
            <!-- press "ctrl" and "+" key together
            and see the effect -->
            Welcome to GfG!

Before click anything.

After clicking 2 times “ctrl” and “+” key together in keyboard.

My Personal Notes arrow_drop_up
Recommended Articles
Page :