<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<b id="oldnode">JavaScript</b>是一个很常用的技术,为网页添加动态效果。
<a href="javascript:replaceMessage()"> 将JavaScript改为JAVA</a>
<script type="text/javascript">
function replaceMessage(){
var newnode=document.createElement("i");
var newnodeText=document.createTextNode("java");
newnode.appendChild(newnodeText);
var oldNode=document.getElementById("oldnode");
oldNode.parentNode.replaceChild(newnode,oldNode);
}
</script>
</body>
</html>
从新拷贝下代码就又好了。哎