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