jQuery - Height / Width

Query has several important methods for working with dimensions:

  • width() gets or sets the current computed width for the element (subtracting padding, border and margin).
  • height() gets or sets the current computed height for the element (subtracting padding, border and margin).
  • innerWidth() gets or sets the current computed inner width (including padding but not border) for the element.
  • innerHeight() gets or sets the current computed inner height (including padding but not border) for the element.
  • outerWidth() get or sets the current computed width for the element (including padding, border, and optionally margin).
  • outerHeight() get or sets the current computed height for the element (including padding, border, and optionally margin).


let message = "";
let width = $("#ImageContainer").innerWidth();
let height = $("#ImageContainer").innerHeight();
message = `The innerWidth is ${width} and the innerHeight is ${height}.`;

$("#btnDemo1").click(function () { $("#msg1").html(message); });
$("#btnDemo2").click(function () { $("#ImageContainer").innerHeight(250).innerWidth(250); } );