编辑下面的代码:【加编码】
<html> <head> </head> <body> <p>点击按钮创建一个title元素。</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> function myFunction() { var x = document.createElement("TITLE"); var t = document.createTextNode("HTML DOM 对象"); x.appendChild(t); document.head.appendChild(x); document.getElementById("demo").innerHTML="现在你已经成功在文档的 HEAD 部分添加了 TITLE 元素。"; }; </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂