通过数组循环到div?

时间:2015-05-01 00:41:29

标签: javascript html list

我试图将此字符串中包含一个月的p元素添加到ID为&#34的div;写"。如何让这个循环遍历字符串列表并将它们添加到div?

var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October","November", "December"];
var element = document.getElementById("write").innerHTML = months;
for (var i = 0; i <= months; i++) {
var para = document.createElement("p");
var text = document.createTextNode(i);
}

我不明白为什么它不起作用。谢谢!

0 个答案:

没有答案