如何使用 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."