Snippet

Contenu de la hauteur de la hauteur de TextArea

4 réponses de la communauté

  resize: none;
function autoResize() {
	console.log('resizing');
	textInput.style.height = (textInput.scrollHeight) + 'px';
}
const textarea = document.getElementById("txt");

textarea.addEventListener("input", function (e) {
  this.style.height = "auto";
  this.style.height = this.scrollHeight + "px";
});
$('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';
});