textarea值更新,但不删除以前的Javascript

我试图在文本区域中插入新数据而不影响上一个数据的方法:

<textarea class="form-control" rows="5" id="data" name="data">
roma is the most visit
</textarea>

  $("#data").val('new line without delete the previous one ');

我期望什么:

<textarea class="form-control" rows="5" id="data" name="data">
roma is the most visit
new line without delete the previous one 
</textarea>

那我该怎么办呢?

jasonzhuhello 回答:textarea值更新,但不删除以前的Javascript

使用.append()代替.val()doc):

$("#data").append('new line without delete the previous one ');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="form-control" rows="5" id="data" name="data">
roma is the most visit
</textarea>

本文链接:https://www.f2er.com/2601458.html

大家都在问