CreateElement with id?
You should use the .setAttribute()
method:
g = document.createElement('div');
g.setAttribute("id", "Div1");
You can use g.id = 'desiredId'
from your example to set the id of the element you've created.
You should use the .setAttribute()
method:
g = document.createElement('div');
g.setAttribute("id", "Div1");
You can use g.id = 'desiredId'
from your example to set the id of the element you've created.