开发者

change <br /> to \n\r in firefox and chrome [closed]

开发者 https://www.devze.com 2023-04-11 07:39 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have done text replacement in Javascript such that the <br /> tag will be replaced by the \n\r . This seems to work in IE8.开发者_开发知识库0 but not in chrome and firefox. why is that so? How can I make it work in chrome and firefox. Why does chrome and firefox not consider <br/> tags as <br/> but rather <br>?


This seems to be working fine everywhere:

"Hello<br />World".replace(/<br\s*\/?>/ig, "\r\n");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号