gpt4 book ai didi

javascript - 如何限制文本区域并从文本区域移动到另一个文本区域

转载 作者:行者123 更新时间:2023-11-28 09:28:28 25 4
gpt4 key购买 nike

我正在构建“所见即所得”,但遇到了一个小问题:

我有 2 个文本区域。

我想限制第一个文本区域的书写量,当我写完后,自动在第二个文本区域继续书写。

就像在“Word”中一样:

http://postimg.org/image/5cuoxf6c9/

我正在使用 execCommand,所以我不希望它依赖于字体大小/空白等...

最佳答案

试试这个:

<textarea id="firstTextArea" maxlength="100" />
<textarea id="secondTextArea" />

使用这个脚本:

<script>
$("#firstTextArea").on("keypress", function(){
if($("#firstTextArea").length == 100){
$("#secondTextArea").focus();
}
}
<script>

关于javascript - 如何限制文本区域并从文本区域移动到另一个文本区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25809738/

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