1<!-- textarea rows attribute -->
2<textarea id="txtid" name="txtname" rows="4" cols="50" maxlength="200">
3A nice day is a nice day.
4Lao Tseu
5</textarea>
1$('textarea').each(function () {
2 this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
3}).on('input', function () {
4 this.style.height = 'auto';
5 this.style.height = (this.scrollHeight) + 'px';
6});