使用 javascript 格式化文本拾取 textarea 的问题

The problem of formatting text pick up textarea with javascript

由于换行符(输入),我无法将下面的代码放入 "textarea":

1) 安装

2) 好的

3) 喜欢

如果我在不中断行的情况下写这个就可以了:

1) 安装 2) 好的 3) 喜欢

有什么办法可以把代码放到textarea中而不干扰代码?以上代码是从数据库(BBcode)中修复的。

html

<textarea class="message" rows="10" cols="60"></textarea>

javascript

$('.message').html('1) install
2) Ok
3) Like'); 

演示:https://jsfiddle.net/v9kpdn4t/

<textarea>

使用 val() 而不是 html()

const str=`1) install

2) Ok

3) Like

html`

$('.message').val(str)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="message" rows="10" cols="60"></textarea>