Convert HTML Entities - how?

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:

Alternatively you could also use some js libraries like He.js, explained on this article:

1 Like