jQuery Getting and setting width and height of an element Getting and setting outerWidth and outerHeight (including padding and border)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Get width and height (excluding margin):

var width = $('#target-element').outerWidth();
var height = $('#target-element').outerHeight();

Get width and height (including margin):

var width = $('#target-element').outerWidth(true);
var height = $('#target-element').outerHeight(true);

Set width and height:

$('#target-element').outerWidth(50);
$('#target-element').outerHeight(100);


Got any jQuery Question?