为什么只能改过去,不能改回来
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<div><i id="oldnode">JavaScript</i>是一个很常用的技术,为网页添加动态效果。</div>
<a href="javascript:replaceMessage()"> 将加粗改为斜体</a><br/>
<a href="javascript:replaceMessage1()">将斜体改为粗体</a>
<script type="text/javascript">
function replaceMessage(){
var oldHTML= oldnode.innerHTML;
var newnode=document.createElement("b");
var oldNode=document.getElementById("oldnode");
oldNode.parentNode.replaceChild(newnode,oldNode);
newnode.innerHTML=oldHTML;
}
function replaceMessage1(){
var oldHTML=oldnode.innerHTML;
var newnode=document.createElement("b");
var oldNode=document.getElementById("oldnode");
oldNode.parentNode.replaceChild(newnode,oldNode);
newnode.innerHTML=oldHTML;
}
</script>
</body>
</html>