Reputation: 2035
i want to dynamically add div element to my page.searching around including Stackoverflow gives me this sample code:
var main = document.getElementById('MasterContainer'); //manually defined div with this id
var div = document.createElement('div');
div.setAttribute("id","container1");
main.appendChild(div);
note: its inside a document.ready function.
and the result does not contain container1 div.
Upvotes: 3
Views: 4346
Reputation: 1911
The code should be fine, check if the element with id #MasterContaienr is on the page and the name has been write well
Upvotes: 1