CreateElement with id?
I'm trying to modify this code to also give this div item an ID, however I have not found anything on google, and idName does not work. I read something about append, however it seems pretty complicated for a task that seems pretty simple, so is there an alternative? Thanks :)
g=document.createElement('div'); g.className='tclose'; g.v=0;
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.
var g = document.createElement('div');
g.id = 'someId';