Open In App

jQuery innerWidth() Method

Last Updated : 10 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads