// needs JQuery // might actually handle divs too in addition to textareas sS hjs_autoExpandingTextAreas() { ret hcss([[ .auto-expand { max-height: 30em; vertical-align: top; } ]]) + hjs([[ var autoExpandTextArea = function (ta) { ta.style.height = "1px"; // Get the computed styles for the element var computed = window.getComputedStyle(ta); var h = ta.scrollHeight + parseInt(computed.getPropertyValue('border-top-width')) + parseInt(computed.getPropertyValue('border-bottom-width')); ta.style.height = h + 'px'; }; document.addEventListener('input', function (event) { if (!event.target.classList.contains("auto-expand")) return; autoExpandTextArea(event.target); }, false); $(document).ready(function() { $(".auto-expand").each(function() { autoExpandTextArea(this); }); }); ]]); }