user1083596
user1083596

Reputation: 145

Rendering escaped HTML content into HTML in DOM

I have a escaped html . I want this to be rendered as HTML components using js or jquery. Any Idea?

Html to render "<strong>Direct Cost Savings, Oracle CRM Replacement </strong> <ul><li>x users, y portal users</li><li>Integrations: Cisco (CTI), Cognos </li><li>Replacements: Oracle CRM (on-premise), RightNow</li><li>First of five phased deployments completed</li></ul>"

Upvotes: 3

Views: 3503

Answers (2)

UltraInstinct
UltraInstinct

Reputation: 44444

You could do something like this:

$('#item').html($("<div/>").html(yourString).text());

Upvotes: 0

David Hedlund
David Hedlund

Reputation: 129792

Use .text() to get the brackets output by first rendering the &lt; etc, and set that text as the html source:

var container = $('#render-target');
container.html(htmlToRender);
container.html(container.text());

Upvotes: 1

Related Questions