From d0576188e081ceaedc397b8f9640d2938c22bcce Mon Sep 17 00:00:00 2001 From: troy Date: Sat, 11 Sep 2021 09:40:55 +0200 Subject: [PATCH] add autoheight for textarea (again) --- autosize.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 autosize.js diff --git a/autosize.js b/autosize.js new file mode 100644 index 0000000..eabae69 --- /dev/null +++ b/autosize.js @@ -0,0 +1,10 @@ +function autosize(tx) { + for (let i = 0; i < tx.length; i++) { + tx[i].setAttribute("style", "height:" + (tx[i].scrollHeight) + "px;overflow-y:hidden;"); + tx[i].addEventListener("input", OnInputAutoSize, false); + } +} +function OnInputAutoSize() { + this.style.height = "auto"; + this.style.height = (this.scrollHeight) + "px"; +} \ No newline at end of file