Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

jQuery | innerWidth() with Example

  • Last Updated : 13 Feb, 2019

The innerWidth is an inbuilt method in jQuery which 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:

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!




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

Output:
Before clicking on the paragraph-

After clicking on the paragraph-




My Personal Notes arrow_drop_up
Recommended Articles
Page :