Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reading html content with without escaping?

I am trying to read the html content using innerHTML. It seems to convert the ‘<‘ in the text content to '&lt;' .

I would rather not to. Is there anything in JS that would allow me to render as such

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Lodash supports an unescape() function that does this.

For example,

// This reads < as &lt;
let html = document.querySelector('.el').innerHTML
// This converts the &lt; back into <
html = _.unescape(html)

More answers are available in this question: Unescape HTML entities in JavaScript?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading