How to attach a DIV to another DIV using DOM

Asked

Viewed 119 times

0

var X = createElement('div');
document.body.appendChild(X);

var Y = createElement('div);

as an attachment to div X to div Y?

  • When you say "attach" you mean put "next to" or "inside"?

1 answer

2

Instead of document.body.appendChild(X); (that attached to the body), use:

Y.appendChild(X);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.