/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE HTML> <html> <body> <textarea id="txtarea" style="width: 100px;,font-size: 16px;line-height: 1; height: 16px;"></textarea> <script type="text/javascript"> document.getElementById('txtarea').addEventListener('keyup', function () { this.style.height = 0; // this is necessary to make it shrink when deleting this.style.height = this.scrollHeight + 'px'; }, false); </script> </body> </html>