Using javascript, how to convert a character to an HTML Entities? For example, I want to convert & to &
Hi, you could use regular expressions for that.
Take a look at this nice answer from Chris Baker on Stack Overflow: https://stackoverflow.com/a/18750001
Alternatively you could also use some js libraries like He.js, explained on this article: https://ourcodeworld.com/articles/read/188/encode-and-decode-html-entities-using-pure-javascript
1 Like