Hello everyone,
I am trying to create html like this

html code

   <div id="windwo">
  <div id="windowhead">
  </div>
  </div>

And this is my try
**Js cose **

   var div = document.createElement('div');
        div.id = 'window';
        var div = document.createElement('div');
        div.id = 'windowhead';
        document.body.appendChild(div);
        document.body.appendChild(div);
Member Avatar for stbuchok

Try this:

var div1 = document.createElement('div');
var div2 = document.createElement('div');

div1.id = 'window';
div2.id = 'windowhead';

div1.appendChild(div2);

document.appendChild(div1);

You need to create two different variables and then append one to the other and the other to the document.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.