我有一个从REST服务返回的对象,该对象的一个属性应该是多行文本,有时它会像html中的以下内容一样返回(在开发工具中查看时)
"this point will be as follows: ↵↵1- point info here ↵2- point2 info here
有时它会在html中显示为:
this point will be as follows:
1- point info here
2- points2 info here
但实际上,在页面上,所有内容都在一行上呈现。
使用以下代码将此文本添加到html元素时:
$("#elementId").html(myValue); //value
是我上面提到的文字。
其中elementId是段落标记。它没有将值设置为文本的多行。
注意:我从SharePoint获取值,我还是新手。知道为什么.html()不正常,特别是在第二种情况下?
由于
答案 0 :(得分:2)
int
myValue = myValue.replace(/↵/g, "<br/>");
&#13;