添加和删除HTML节点的简单示例-XHTML教程

来源:模板无忧 作者:织梦幻影Juven 更新时间:2007-12-02 点击:

添加和删除HTML节点的简单示例

<input type="button" onclick="appendnode()" value="添加节点">
<input type="button" onclick="removenode()" value="删除节点">
<div id="result"></div>
<script>
i=0
function appendnode() {
o=document.createElement("DIV");
o.innerHTML="test" i
document.getElementById('result').appendChild(o);
i
}

function removenode(){
var x = document.getElementById('result');
x.removeChild(x.lastChild) //从最后个节点删除
}
</script>

相关XHTML教程:
最新评论:
loading.. 评论加载中....
发表评论:不能超过250字节,请自觉遵守互联网相关政策法规.
  • 昵称: 验证:

最新XHTML教程