1$(document)
2 .one('focus.textarea', '.autoExpand', function(){
3 var savedValue = this.value;
4 this.value = '';
5 this.baseScrollHeight = this.scrollHeight;
6 this.value = savedValue;
7 })
8 .on('input.textarea', '.autoExpand', function(){
9 var minRows = this.getAttribute('data-min-rows')|0,
10 rows;
11 this.rows = minRows;
12 rows = Math.ceil((this.scrollHeight - this.baseScrollHeight) / 16);
13 this.rows = minRows + rows;
14 });
15