Get height or width of an element in Javascript

Get height or width of an element in Javascript

Example: We cet height and width of the div use Id "abc"

const el = document.getElementById("abc");
const eHeight = el.offsetHeight;
const eWidth = el.offsetWidth;


The offsetHeight property returns the viewable height of an element in pixels, including padding, border and scrollbar (except for the margin)
The offsetWidth property returns the viewable width of an element in pixels, including padding, border and scrollbar (except for the margin)


© 2019 4codev

Created with love by Sil.