jQuery Tutorial

jQuery outerWidth() Method With Syntax and Example

Understanding outerWidth method in jQuery

The outerWidth() method returns the first matching element's outer width. This approach incorporates padding and border, as shown in the figure below. Use outerWidth to include the margin (actual).

outerWidth method in jQuery

Syntax of outerWidth method in jQuery

$(selector).outerWidth(includeMargin)

Example of jQuery outerWidth method

The outer width of a

element is returned:

$("button").click(function(){
  alert($("div").outerWidth());
});
Did you find this article helpful?