I am trying to use Javascript to shrink and grow automatically as the height of the scroll is increasing. The growing the height of textarea is achieved but when I am deleting the texts I can't figure out how to shrink the size.... I don't want to use the jQuery functions.
My code is:
<html>
<head>
<script>
function func() {
var ta = document.getElementById('mytexta');
ta.value+=ta.scrollHeight+' '+ta.clientHeight;
if(ta.scrollHeight>ta.clientHeight)
{
ta.style.overflow='hidden';
ta.rows+=1;
}
}
</script>
</head>
<body>
<textarea class="mytext" onkeyup="func()" id="mytexta" style="overflow:hidden;">Here we go</textarea>
</body>
</html>