
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery outerWidth Method
The outerWidth() method in jQuery is used to return the width of an element. The method includes padding and border.
Output
The syntax is as follows−
$(selector).outerWidth(margin)
Above, the margin is a Boolean value to specify whether or not to include the margin. TRUE is to include the margin.
Example
Let us now see an example to implement the jQuery outerWidth() method−
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ document.getElementById("demo").innerHTML = "<br>Outer Width of DIV = " + $("div").outerWidth() }); }); </script> </head> <body> <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> </body> </html>
Output
This will produce the following output−
Click “Outer width of div” to get outer width−
Advertisements