改变< br />在Firefox和Chrome中的\ n \\\ [英] change <br /> to \n\r in firefox and chrome

查看:84
本文介绍了改变< br />在Firefox和Chrome中的\ n \\\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Javascript中进行了文本替换,以便< br /> 标记将替换为 \ n \\\ 。这似乎适用于IE8.0,但不适用于chrome和firefox。为什么会这样?如何在chrome和firefox中使其工作。为什么chrome和firefox不会将< br /> 标记为< br /> 而是< br>

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>?

推荐答案

这似乎无处不在:

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

这篇关于改变&lt; br /&gt;在Firefox和Chrome中的\ n \\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆