CreateElement with id? September 22, 2022 by Tarik You should use the .setAttribute() method: g = document.createElement('div'); g.setAttribute("id", "Div1");