innerWidth() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:innerWidth

Description

The innerWidth() method returns the inner width including padding, but not border and margin of the FIRST matched element.

The following code shows how to Return the inner width of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        console.log("Inner width of div: " + $("div").innerWidth());
    });/*from w  ww  .j  a  v  a2s  . com*/
});
</script>
</head>
<body>

<div style="height:100px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:red;"></div><br>

<button>Display the inner width of div</button>

</body>
</html>

Related Tutorials