Reputation: 791
I have the following JSON object:
comment: "Test Comments Feature<br>"
When I display it on my modalBox, $('#myModal #comments'+i+'').text(test.comment);
the HTML tag isn't being rendered:
Output: Test Comments Feature<br>
I tried using JSON.parse(test.comment)
and JSON.stringify(test.comment)
But I could not achieve the desired result:
Test Comments Feature
What am I missing? Can JSON objects render HTML automatically?
Upvotes: 0
Views: 631
Reputation: 943
.text()
method will strip html tags, use .html()
method instead:
$('#myModal #comments'+i+'').html(test.comment);
Upvotes: 2