これは私のスクリプトです:
function expandtext(textArea){
while (
textArea.rows > 1 &&
textArea.scrollHeight < textArea.offsetHeight
){
textArea.rows--;
}
var h=0;
while (textArea.scrollHeight > textArea.offsetHeight && h!==textArea.offsetHeight)
{
h=textArea.offsetHeight;
textArea.rows++;
}
textArea.rows++
}
HTML:
<textarea class="expta" onkeyup="expandtext(this);" style="overflow-y:hidden;"></textarea>
これまでのところ、すべて正常に動作しています。しかし、テキストエリアの高さを追加すると:
<textarea class="expta" onkeyup="expandtext(this);" style="height:16px;overflow-y:hidden;"></textarea>
もう機能しません。何か案は?