'Reading html content with without escaping? [duplicate]
I am trying to read the html content using innerHTML. It seems to convert the '<' in the text content to '<' .
I would rather not to. Is there anything in JS that would allow me to render as such
Solution 1:[1]
Lodash supports an unescape() function that does this.
For example,
// This reads < as <
let html = document.querySelector('.el').innerHTML
// This converts the < back into <
html = _.unescape(html)
More answers are available in this question: Unescape HTML entities in JavaScript?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | S Anand |
