1

var encodedHtml = "<ol style="color: rgb(34, 34, 34); font-family: arial, sans-serif;"><li class="mod" style=""> <div class="_oDd" style=""><span class="_Tgc" style="font-size: 16px;"><b>Test data</b> is <b>data</b>

which has been specifically identified for use in <b>tests</b>, typically of a computer program. Some <b>data</b> may be used in a confirmatory way, typically to verify that a given set of input to a given function produces some expected result.</span></div> </li></ol>";

I want to change this content to html tags , so i can add it to some div using js.

Amin Jafari
  • 7,157
  • 2
  • 18
  • 43
Ankuli
  • 131
  • 7

2 Answers2

1

This should get you sorted out:

What's the right way to decode a string that has special HTML entities in it?

A few answers down it has a jQuery version:

function htmlDecode(value) {
    return $("<textarea/>").html(value).text();
}
Community
  • 1
  • 1
Cory
  • 1,794
  • 12
  • 21
0

var encodedHTML = "&lt;ol style=&quot;color: rgb(34, 34, 34); font-family: arial, sans-serif;&quot;&gt;&lt;li class=&quot;mod&quot; style=&quot;&quot;&gt; &lt;div class=&quot;_oDd&quot; style=&quot;&quot;&gt;&lt;span class=&quot;_Tgc&quot; style=&quot;font-size: 16px;&quot;&gt;&lt;b&gt;Test data&lt;/b&gt; is &lt;b&gt;data&lt;/b&gt; which has been specifically identified for use in &lt;b&gt;tests&lt;/b&gt;, typically of a computer program. Some &lt;b&gt;data&lt;/b&gt; may be used in a confirmatory way, typically to verify that a given set of input to a given function produces some expected result.&lt;/span&gt;&lt;/div&gt; &lt;/li&gt;&lt;/ol&gt;";

$("<p/>").html(encodedHTML ).text();

this also works.

Ankuli
  • 131
  • 7