我想在文本区域中的每个逗号后面输入新行。
<textarea id="update_destination" placeholder="Podpiete adresy" class="form-control"></textarea>
下面是我如何填写我的文本区域
$("#update_destination").val(alias.destination);
别名是一个对象。
现在,在我的文本区,我得到了类似xxx、yyy、zzz的内容我想要:
xxx
yyy
zzz
试试这个代码:
$('#update_destination').val(alias.destination.split(",").join("n"));
你可以检查一下这个小提琴你的容易
有关replace all occurrences of all string
的更多详细信息,请参阅此堆栈溢出链接