插入一个元素的步骤
1、创建一个节点;createElement
2、找到一个节点;getElementById
3、插入元素;appendChild
<script type="text/javascript">
DOM.addEvent(window,'load',function(){
var node = DOM.$('firefox');
var de = node.ownerDocument;
DOM.log.write(de);
DOM.log.header('Append Child');
var newChild = document.createElement('LI');
newChild.appendChild(document.createTextNode('A new list item!'));
var list = document.getElementById('firefox');
list.appendChild(newChild);
});
</script>
html:
<div>
<ul>
<li id='firefoxListItem' title="firefox">
<a href="#" title="get Firefox" id="firefox">Firefox 2.0</a>
</li>
<li>
<a href="#" title="getMicrsoft Inter" id='msie'>ie11</a>
</li>
<li>
<a href="#" title="check out safari" id='safari'>safari</a>
</li>
<li>
<a href="#" title="getOpera" id='Opera'>Opera</a>
</li>
</ul>
</div>