gpt4 book ai didi

jquery - 文本区域高度根据内容高度增加

转载 作者:行者123 更新时间:2023-12-01 07:10:17 24 4
gpt4 key购买 nike

我需要根据内容增加文本区域的高度。如果用户输入内容,它会自动增加。如果删除内容则需要降低高度。

最佳答案

是的,我得到了答案,它工作正常。

<textarea onkeyup="textAreaAdjust(this)" placeholder="Add a new answer" rows="1"></textarea>


<script type="text/javascript">
function textAreaAdjust(o) {
o.style.height = "1px"; o.style.height = (25+o.scrollHeight)+"px"; }
</script>

关于jquery - 文本区域高度根据内容高度增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29114806/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com