javascript - How to parse HTML tags from JSON Object -
i have json object has value of html styles. tried including in html using jquery append
.
the value getting appending, not converting normal dom, appending whole thing string.
this json object value:
var obj = { content : "<p><linkrel="stylesheet"type="text/css"href="http:<p><styletype="text/css"><br/>.wrap{<br/> background-color:#f6f6f6;<br/>}<br/></style></p><p><divclass="wrap"><br/> </div></p>" }
this tried:
html:
<div id='container'></div>
js:
$('#container').append(obj.content);
output should part of dom, instead printing entire thing string.
you can ...
var obj = { content : '<p><style>.wrap{color:red}</style><div class="wrap">aa</div></p>' } $('span').append($(document.createelement('div')).html(obj.content).text());
fiddler: https://jsfiddle.net/suscmguy/
your obj.content
seems have invalid / incomplete encoding
hope helps...
Comments
Post a Comment