Skip to content
Related Articles

Related Articles

jQuery | innerWidth() with Example

Improve Article
Save Article
  • Last Updated : 13 Feb, 2019
Improve Article
Save Article

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


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:

<!DOCTYPE html>
        <!--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();
    <div style="height: 100px;width: 200px; background-color: blue">
    <p>Click here to know innerWidth</p>
    <p id="demo"></p>

Before clicking on the paragraph-

After clicking on the paragraph-

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!