Quantcast
Channel: How to auto-size a textarea in height? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by DanMan for How to auto-size a textarea in height?

$
0
0

This function will set the height of the element (textarea, in your case) to the browser's default height. If that causes a scrollbar to appear, the height will be switched to the actually needed height.

function autoHeight(element){    element.style.height='auto';    element.style.height=element.scrollHeight+'px';}

If you don't like the browser's default height, you can change that to some other default value of your own, of course.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>