jQuery outerWidth() Method

jQueryWeb DevelopmentFront End Technology

The outerWidth() method in jQuery is used to return the width of an element. The method includes padding and border.


The syntax is as follows−


Above, the margin is a Boolean value to specify whether or not to include the margin. TRUE is to include the margin.


Let us now see an example to implement the jQuery outerWidth() method

 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
         document.getElementById("demo").innerHTML = "<br>Outer Width of DIV = " + $("div").outerWidth()
<h2>Rectangular Box</h2>
<div style="height:200px;width:500px;padding:30px;margin:1px;background-color:blue;"></div><br>
<button>Outer width of div</button>
<p id="demo"></p>


This will produce the following output−

Click “Outer width of div” to get outer width−

Updated on 30-Dec-2019 09:16:28