javascript - Create html div with Js -
i trying create html code in js
this html code how want javascript
<div id="windwo"> <div id="windowhead"> </div> </div>
and javascript code test
var div = document.createelement('div'); div.id = 'window'; var div = document.createelement('div'); div.id = 'windowhead'; document.body.appendchild(div); document.body.appendchild(div);
and out put of javascript code
<div id="windowhead"></div>
someone can tell me mistake done ?
you need 2 div variables , append second div first:
var div = document.createelement('div'); div.id = 'window'; var div2 = document.createelement('div'); div2.id = 'windowhead'; div.appendchild(div2); document.body.appendchild(div);
you overwriting first div second div.
Comments
Post a Comment