參考。該網(wǎng)頁(yè)不行,到chrome里可以正常運(yùn)行。
<!DOCTYPE HTML>
<html>
<head>
? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ? <title>無(wú)標(biāo)題文檔</title>
</head>
<body>
? ? <div><b id="oldnode">JavaScript</b>是一個(gè)很常用的技術(shù),為網(wǎng)頁(yè)添加動(dòng)態(tài)效果。</div>
? ? <a href="javascript:replaceMessage()"> 將加粗改為斜體</a>
? ? <script type="text/javascript">
? ? ? ? function replaceMessage(){
? ? ? ? ? ? var node1=document.getElementById("oldnode");
? ? ? ? ? ? var node2=document.createElement("i");
? ? ? ? ? ? var node3=document.createTextNode("JavaScript");
? ? ? ? ? ? node2.appendChild(node3);
? ? ? ? ? ? node1.parentNode.replaceChild(node2,node1);
? ? ? ? }? ??
? ? </script>
</body>
</html>