Skip to content
Advertisement

Parse html from JSON file

I’m trying to get HTML tags to work in my json-file that i fetch via js.

So i want the return to somehow make the <strong> to work when render it on the page. How would i do that?

Sample of the json:

JavaScript

JS:

JavaScript

To render it i do like so: pseudo.

JavaScript

Advertisement

Answer

Change innerText to innerHTML. When you use the text method, it escapes the html characters. Innerhtml renders the exact html.

JavaScript
Advertisement