Abdul Diaz Abdul Diaz - 2 months ago 6
jQuery Question

Parse Javascript as HTML

I have tried everything. My code doesn't render as HTML, instead it is just raw text.

This is my code:

$('#question').parseHTML(quiz[currentquestion]['question']);


How do I fix this?

Answer

Did you mean to use html() as output?

$('#question').html(quiz[currentquestion]['question']);

Or like this with $.parseHTML which is to parse a string into an array of DOM nodes.

var html = $.parseHTML(quiz[currentquestion]['question']);
$('#question').html(html);
Comments