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 š
JavaScript
āx
2
1
g=document.createElement('div'); g.className='tclose'; g.v=0;
2
ā
Advertisement
Answer
You should use the .setAttribute()
method:
JavaScript
1
3
1
g = document.createElement('div');
2
g.setAttribute("id", "Div1");
3
ā