Javascript examples for jQuery Method and Property:outerWidth
The outerWidth() method returns the outer width including padding and border of the FIRST matched element.
Parameter | Require | Data Type | Description |
---|---|---|---|
includeMargin | Optional. | A Boolean value | whether to include the margin |
The following code shows how to Return the outer width of a <div> element:
<!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("Outer width of div: " + $("div").outerWidth()); });//from www . j a va2 s. c o m }); </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 outer width of div</button> </body> </html>