Forum Moderators: open
<script>
function addMyNode() {
node = document.getElementById("#001");
element = document.createElement('li');
text = document.createTextNode('Child 2');
element.appendChild(text, null);
node.appendChild(element, null);
}
</script>
Called with:
<ul id="#001">
<li>Child 1</li>
</ul>
<input type="button" value="Insert new Node" onClick="addMyNode()"></input>
I wanted to use a DocumentFragment to append several children in one go, but the method createDocumentFragment just returns an empty one, as opposed to parsing the contents of a parameter. Anyone have any ideas?
Neil