I have some problem. Me need to create dynamically - 40 div's in one container by Javascript (div also). Like a calendar days in calendar . Please help ! Don't know how to do that.
Asked
Active
Viewed 249 times
0
-
1Have you tried? Have any code? – Nunchy Aug 06 '16 at 13:10
-
`var container = document.getElementById("contianer"); for (var i = 0; i < 40; i++) { var child = document.createNode("div"); container.appendChild(child) }` – VLAZ Aug 06 '16 at 13:10
-
Ohhhh.... thanks a lot )) It worked!:) – Maksym Domaretskyi Aug 06 '16 at 13:19
1 Answers
0
Take a look at this question:
Code from the answer (modified):
//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...
Also check this tutorial for appendChild out