JavaScript – Change the Width of HTML Element
To change the width of a HTML Element using JavaScript, get reference to this HTML Element element, and assign required value to the element.style.width
property.
In the following example, we will change the width of HTML Element with id "myElement"
to "150px"
, in JavaScript, using element.style.width
property.
example.html
ADVERTISEMENT
Conclusion
In this JavaScript Tutorial, we learned how to change the width of a HTML Element using JavaScript.