CreateElement with id?

You should use the .setAttribute() method:

g = document.createElement('div');
g.setAttribute("id", "Div1");

Leave a Comment