<textarea class="common" placeholder="測試測試測試" id="txt"></textarea>
<script type="text/javascript">
const txt = document.getElementById("txt");
txt.addEventListener('input', (e) => {
txt.style.height = 'auto'
txt.style.height = txt.scrollHeight + 2 + 'px';
}, false);
</script>
複製代碼