Answers for "textarea auto height based on initial content length"

6

fix textarea size

resize: none;
Posted by: Guest on May-16-2020
0

textarea height fit content

const textarea = document.getElementById("txt");

textarea.addEventListener("input", function (e) {
  this.style.height = "auto";
  this.style.height = this.scrollHeight + "px";
});
Posted by: Guest on November-18-2021
1

html textarea auto height to amount of text

$('textarea').each(function () {
  this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
}).on('input', function () {
  this.style.height = 'auto';
  this.style.height = (this.scrollHeight) + 'px';
});
Posted by: Guest on June-03-2020

Code answers related to "textarea auto height based on initial content length"

Browse Popular Code Answers by Language