Home >>jQuery Tutorial >jQuery innerWidth() Method

jQuery innerWidth() Method

jQuery innerWidth() Method

jQuery innerWidth() method in jQuery is used to returns the inner width of the FIRST matched element and includes padding, but not margin and border.

Syntax:
$(selector).innerWidth()
Here is an Example of jQuery innerWidth() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
alert("Inner width of div: " + $(".innerwidth1").innerWidth());
});
});
</script>
</head>
<body>
<div class="innerwidth1" style="height:50px;width:150px;padding:12px;margin:2px;border:1px solid #000;background-color:#a4e838;"></div><br>
<button class="btn1">click me to Display the inner width of div</button>
</body>
</html>

Output:


No Sidebar ads