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