Unable to render the html tags dynamically
I am using innerHTML property to insert a span into a div. But the span is not getting displayed immediately on the page. however if we use alert function immeditely after the innerHTML statement, the span is getting displayed. Please help Thanks in adva开发者_运维百科nce,
Regards,
Robin
Try using DOM method:
// Create the span
var span = document.createElement('span');
//set attributes you want
span.setAttribute('id','mySpanId');
//Then append as child of the div you want
document.getElementById('myDivContainer').appendChild(span);
精彩评论