h...">

How to replace character in text by jquery

How to replace a character in a text For example,

 <script>alert("Hi i am nishant");</script>

here I want to replace <and> with ASCII code, since I will replace it.

+5
source share
1 answer
var text = text.replace(/</g, "&lt;").replace(/>/g, "&gt;");
+6
source

All Articles