简体   繁体   中英

How to replace a Character in text By jquery

How to replace a charcter within a text For instance

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

here i want to replace < and > by ASCII code so how i will replace it.

var text = text.replace(/</g, "&lt;").replace(/>/g, "&gt;");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM