I can not understand the essence of the error. According to the idea here is something with types. It is necessary to add object through appendChild
, and I add a line.
window.onload = function(){ var mainDiv = document.createElement('div'); mainDiv.id = 'mainDiv'; document.body.appendChild(mainDiv); var buttonControl = { 'paragraf': '<a href = "#paragraf" id="paragraf">p</a>', 'bold': '<a href = "#bold" id="bold">b</a>', 'italic': '<a href = "#italic" id="italic">i</a>' }; for(var property in buttonControl){ mainDiv.appendChild(buttonControl[property]); } };
Throws an error like this: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8