Convert tags to html entities

后端 未结 7 689
小蘑菇
小蘑菇 2020-12-08 17:16

Is it possible to convert html tags to html entities using javascript/jquery using any way possible such as regex or some other way. If yes, then how?

Exampl

7条回答
  •  攒了一身酷
    2020-12-08 17:40

    There's a concise way of doing this using String.prototype.replace() and regular expressions as follows:

    var tag = "

    This should

    be bold

    and big

    "; var escapedTag = tag.replace(//g, ">");

提交回复
热议问题