E
eggie5
I have the following function that build a div and adds it to the page.
function setDataJSON(req)
{
var data = eval('(' + req.responseText + ')');
console.log(data.news.length);
for (var i=0;i<data.news.length;i++)
{
var x = document.createElement('div');
var y = document.createElement('h3');
y.appendChild(document.createTextNode(data.news.story.headline));
x.appendChild(y);
var z = document.createElement('p');
z.className = 'moreInfo';
z.appendChild(document.createTextNode( data.news.story.summary ));
x.appendChild(z);
var a = document.createElement('img');
a.src = data.news.story.cover;
x.appendChild(a);
var b = document.createElement('p');
b.appendChild(document.createTextNode(data.news.story.body));
x.appendChild(b);
$('writeroot').appendChild(x);
}
}
A lot of my text in my textnodes: headline, summary and body have HTML
tags. However when i ad them to my page, they show ups literal text.
For example if body has the text of <b>bold text</b> it show up
literally like that instead of 'bold text' in bold. How can I have it
render the HTML?
function setDataJSON(req)
{
var data = eval('(' + req.responseText + ')');
console.log(data.news.length);
for (var i=0;i<data.news.length;i++)
{
var x = document.createElement('div');
var y = document.createElement('h3');
y.appendChild(document.createTextNode(data.news.story.headline));
x.appendChild(y);
var z = document.createElement('p');
z.className = 'moreInfo';
z.appendChild(document.createTextNode( data.news.story.summary ));
x.appendChild(z);
var a = document.createElement('img');
a.src = data.news.story.cover;
x.appendChild(a);
var b = document.createElement('p');
b.appendChild(document.createTextNode(data.news.story.body));
x.appendChild(b);
$('writeroot').appendChild(x);
}
}
A lot of my text in my textnodes: headline, summary and body have HTML
tags. However when i ad them to my page, they show ups literal text.
For example if body has the text of <b>bold text</b> it show up
literally like that instead of 'bold text' in bold. How can I have it
render the HTML?