我试图将此字符串中包含一个月的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);
}
我不明白为什么它不起作用。谢谢!