innerHTML adds text but not HTML tags



Maybe, you are using += with innerHTML. Try the following:

var myNum = [1,2,3];
var myStr;
myStr = "<ul>";

for( var a in myNum)
myStr += "<li>" + a + "</li>";
myStr += "</ul>";
id("numberList").innerHTML = myStr;

Advertisements