jQuery – Dimension Methods

We all know about Margins, Padding, Borders, etc of an element, but some jQuery built-in methods also calculate the dimensions of an element on a web page. These methods get or set the width or height of an element and also cover the concept of excluding and/ or including padding, border, and margin. The following are the methods:

  • width(): Get or set the width of an element. Excludes padding, border, and margin
  • height(): Get or set the height of an element. Excludes padding, border, and margin
  • innerWidth(): Get or set the width of an element. Includes the padding
  • innerHeight(): Get or set the height of an element. Includes the padding
  • outerWidth(): Get or set the width of an element. It includes the padding and border
  • outerHeight(): Get or set the height of an element. It includes the padding and border

jQuery width() method

The width() method in jQuery is used to get or set the width of an element. It excludes padding, border, and margin. Let us see an example:

Output

jQuery width()

jQuery height() method

The height() method in jQuery is used to get or set the height of an element. It excludes padding, border, and margin. Let us see an example:

Output

jQuery height()

jQuery innerWidth() method

The innerWidth() method in jQuery is used to get or set the width of an element. It includes padding. Let us see an example:

Output

jQuery InnerWidth

jQuery innerHeight() method

The innerHeight() method in jQuery is used to get or set the height of an element. It includes padding. Let us see an example:

Output

jQuery InnerHeight() method

jQuery outerWidth() method

The outerWidth() method in jQuery is used to get or set the width of an element. It includes the padding and border. Let us see an example:

Output

jQuery outerWidth() method

jQuery outerHeight() method

The outerHeight() method in jQuery is used to get or set the height of an element. It includes the padding and border. Let us see an example:

Output

jQuery outerHeight() method

jQuery - Toggle CSS Class
jQuery - Get CSS Properties
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading