HtmlSpecialChars equivalent in Javascript?

后端 未结 16 1558
耶瑟儿~
耶瑟儿~ 2020-11-22 06:00

Apparently, this is harder to find than I thought it would be. And it even is so simple...

Is there a function equivalent to PHP\'s htmlspecialchars built into Javas

16条回答
  •  鱼传尺愫
    2020-11-22 06:19

    For Node.JS users (or users utilizing Jade runtime in the browser), you can use Jade's escape function.

    require('jade').runtime.escape(...);
    

    No sense in writing it yourself if someone else is maintaining it. :)

提交回复
热议问题