0

I have a textarea element, and I am trying to find the height of it. Right now, I am using document.getElementById('area').offsetHeight. This does give me the height, however, I am wondering if there is a way to dynamically update this if I enlarge the textarea. Right now, even if I pull on the corner and make the textarea taller, the javascript returns the same result. Is there a way to update the height when I pull the corner?

Matt
  • 85
  • 7

1 Answers1

1

You can use the javascript onmouseup event. Using the console.log you can see that the value changes.

function mouseUp() {
  console.log(document.getElementById('area').offsetHeight);
}
<textarea id="area" onmouseup="mouseUp()"></textarea>
Adjit
  • 10,134
  • 12
  • 53
  • 98
K.Burrell
  • 249
  • 1
  • 3
  • 14
  • Is there a way to store the new height as a variable instead of logging it? – Matt Jun 22 '16 at 17:26
  • @Matt Its just javascript, you'd use it the same as you would anywhere else, i.e. var newHeight; newHeight = document.getElementById('area').offsetHeight; – K.Burrell Jun 23 '16 at 10:31