동일한 프로세스를 사용하십시오. 이미 만든 iDiv원래 요소 <div id='block'>를 참조 하는 변수 가 이미 있습니다 . 다른 것을 만들고 <div>호출하면 appendChild()됩니다.
// Your existing code unmodified...
var iDiv = document.createElement('div');
iDiv.id = 'block';
iDiv.className = 'block';
document.getElementsByTagName('body')[0].appendChild(iDiv);
// Now create and append to iDiv
var innerDiv = document.createElement('div');
innerDiv.className = 'block-2';
// The variable iDiv is still good... Just append to it.
iDiv.appendChild(innerDiv);
http://jsfiddle.net/W4Sup/1/
이벤트 생성 순서는 내가 위에서했던 것처럼 될 필요는 없습니다. innerDiv에 둘을 추가하기 전에 새 div를 외부 div에 번갈아 추가 할 수 있습니다 <body>.
var iDiv = document.createElement('div');
iDiv.id = 'block';
iDiv.className = 'block';
// Create the inner div before appending to the body
var innerDiv = document.createElement('div');
innerDiv.className = 'block-2';
// The variable iDiv is still good... Just append to it.
iDiv.appendChild(innerDiv);
// Then append the whole thing onto the body
document.getElementsByTagName('body')[0].appendChild(iDiv);
document.body.