<br>新增和刪除HTML節點的簡單範例 <br> <input type="button" onclick="appendnode()" value="添加节点"><br><input type="button" onclick="removenode()" value="删除节点"><br><div id="result"></div> <br><script><br />i=0<br />function appendnode() {<br />o=document.createElement("DIV");<br />o.innerHTML="test" i<br />document.getElementById('result').appendChild(o);<br />i <br />}<br />function removenode(){<br />var x = document.getElementById('result');<br />x.removeChild(x.lastChild) //从最后个节点删除<br />}<br /></script>