最佳答案
我如何用JavaScript从值中读取换行符,并将所有换行符替换为<br />
元素?
例子:
从PHP传递的变量,如下所示:
"This is man.
Man like dog.
Man like to drink.
Man is the king."
我希望我的结果在JavaScript转换后看起来像这样:
"This is man<br /><br />Man like dog.<br />Man like to drink.<br /><br />Man is the king."