The essence of the task is such, in the middle of the page there will be a div block in which buttons should appear with absolute positioning. Such a problem, I can not put the generated DOM elements in this very div block. It is necessary that the script-generated elements fit into <div id="menu222"></div>
html
<input type="button" onclick="NewTeg()" value="Добавить кнопку"> <div id="menu222"> </div> Js
function NewTeg() { var d=document.createElement('div'); NUM = (!self.NUM) ? 1 : ++NUM; d.style.textAlign = "center"; d.style.padding = "8px"; d.style.color = "#fff"; d.style.borderRadius ='5px'; d.style.background='#6492cb'; d.style.position='absolute'; d.id ="Dialog" + NUM; d.className = ('drag'); d.innerHTML = NUM; document.body.appendChild(d); }