3👍
✅
As the error message is trying to tell you, clientHeight
is a read only property. You’ll probably want to modify the style.height
property, but keep in mind clientHeight
includes the padding. Try getting the element style using Window.getComputedStyle() and getting the width from there.
However, you can actually achieve this without using any JS at all: http://www.mademyday.de/css-height-equals-width-with-pure-css.html
Source:stackexchange.com