Open In App
Related Articles

jQuery innerWidth() Method

Improve Article
Improve
Save Article
Save
Like Article
Like

The innerWidth is an inbuilt method in jQuery that is used to return the width of the first matched element.

Syntax:

$(selector).innerWidth()

Here selector is the selected element.

Parameters: It does not accept any parameters.

Return value: It returns the width of the selector.

jQuery code to show the working of innerWidth() method:

Example: Here is an example of the above-explained method.

html




<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
    <script>
        //jQuery code to demonstrate innerWidth function
 
        // document ready
        $(document).ready(function () {
            // on clicking the paragraph
            $("p").click(function () {
                // innerWidth
                document.getElementById("demo").innerHTML =
                    "innerWidth = " + $("div").innerWidth();
            });
        });
    </script>
</head>
 
<body>
    <h2 style="color: green;">
        GeeksforGeeks
    </h2>
    <div style="height: 100px;width: 200px;
                background-color: blue">
 
    </div>
    <p>
        Click here to know innerWidth
    </p>
    <p id="demo"></p>
</body>
 
</html>


Output:

jquery-14


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 10 Jul, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials