我希望在我的textarea中每个创建的逗号后输入新行。
<textarea id="update_destination" placeholder="Podpiete adresy" class="form-control"></textarea>
而且我如何填写我的文本区域
$("#update_destination").val(alias.destination);
别名是一个对象。
现在在我的textarea我得到了像xxx,yyy,zzz我想要的东西:
XXX
YYY
ZZZ
试试这段代码:
$('#update_destination').val(alias.destination.split(",").join("\n"));
您可以轻松查看this fiddle
有关this Stackoverflow Link的更多详细信息,请参阅replace all occurrences of all string