In this article we will learn how to get inner width of html elements or how to use innerWidth() method in jQuery with example.


jQuery innerWidth() method is used to return/get the inner width of the first matched element without including border and margin. This method includes padding but excludes border and margin.



Let’s see, Example of jQuery innerWidth() method:

<!DOCTYPE html>
<html xmlns="">
    <title>Example of jQuery innerWidth method</title>
    <script type="text/javascript" src=""></script>    
    <script type="text/javascript">
        $(document).ready(function () {
            $("button").click(function () {
                $("#divWidth").html("Inner width of div is: " + $("#Main").innerWidth());
    <div id="Main" style="height:100px;width:400px;padding:10px;margin:3px
       ;border:1px solid blue;background-color:lightpink;"></div><br>
    <button>Click here to get the inner width of the div</button>
    <div id="divWidth"></div>

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like