document.getElementById("main")
?
You don’t need to assign the first div an id, either.
var div0 = document.createElement("div");
var div1 = document.createElement("div");
var div2 = document.createElement("div");
div0.appendChild(div1);
div0.appendChild(div2);
document.body.appendChild(div0);
3
solved How do I create this with javascript [closed]