Sometimes, we want to set element width or height in JavaScript.
In this article, we’ll look at how to set element width or height in JavaScript.
How to set element width or height in JavaScript?
To set element width or height in JavaScript, we set the style.width
and style.height
properties.
For instance, we write
e1.style.width = "400px";
e1.style.height = "200px";
to set the width of the el
element to 400px and the height of el
to 200px.
Conclusion
To set element width or height in JavaScript, we set the style.width
and style.height
properties.