提问者:小点点

如何在容器Javascript中创建50个div


我有一些问题。Me需要通过Javascript(div)在一个容器中动态创建-40个div。就像日历中的日历日。请帮忙!我不知道怎么做。


共1个答案

匿名用户

看看这个问题:

答案中的代码(已修改):

//Your existing div
var divP = document.getElementById('divParent');

// Now create and append to divP
var innerDiv = document.createElement('div');
innerDiv.className = 'innerDiv';

// Append it to the parent div
iDiv.appendChild(divP);

//Repeat it 40 times...

另外,还可以查看本教程中的appendChild