$("textarea.growable") .on('keyup paste input', function () { let self = $(this); let offset = self.innerHeight() - self.height(); if (self.innerHeight() < this.scrollHeight) { //Grow the field if scroll height is smaller self.height(this.scrollHeight - offset); } else { //Shrink the field and then re-set it to the scroll height in case it needs to shrink self.height(1); self.height(this.scrollHeight - offset); } });