Javascript examples for jQuery Method and Property:outerWidth
Get the outer width with and without margin
<!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(){ var txt = ""; txt += "outerWidth() of div: " + $("div").outerWidth() + "</br>"; txt += "outerWidth(true) of div: " + $("div").outerWidth(true) + "</br>"; $("div").html(txt); });//from w w w.j av a 2 s. co m }); </script> </head> <body> <div style="height:120px;width:300px;padding:10px;margin:3px;border:1px solid blue;background-color:red;"></div><br> <button>Display outer width of div</button> </body> </html>