xxxxxxxxxx
//html
<textarea name="text" oninput="auto_grow(this)"></textarea>
//js
<script>
function auto_grow(element) {
element.style.height = "auto";
element.style.height = (element.scrollHeight)+"px";
};
const x = document.querySelector('#textarea-input')
x.onsubmit = (event) => {
messageBox.style.height = 'auto';}
</script>
xxxxxxxxxx
$('#product_description').each(function() {
console.log(this.scrollHeight)
this.setAttribute("style", "height:" + (this.scrollHeight) + "px;overflow-y:hidden;");
}).on("input", function() {
console.log(this.scrollHeight)
this.style.height = 0;
this.style.height = (this.scrollHeight) + "px";
});
xxxxxxxxxx
function autoResize() {
console.log('resizing');
textInput.style.height = (textInput.scrollHeight) + 'px';
}
xxxxxxxxxx
$('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';
});
xxxxxxxxxx
const tx = document.getElementsByTagName("textarea");
for (let i = 0; i < tx.length; i++) {
tx[i].setAttribute("style", "height:" + (tx[i].scrollHeight) + "px;overflow-y:hidden;");
tx[i].addEventListener("input", OnInput, false);
}
function OnInput() {
this.style.height = 0;
this.style.height = (this.scrollHeight) + "px";
}