JavaScript document方法2
作者:互联网
用js代码创建html标签
appendChild方法可以向一个标签中添加子标签
<head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript"> window.onload = function () { var divObj = document.createElement("div"); divObj.innerHTML = "子涵真帅"; document.body.appendChild(divObj); } </script> </head> <body> </body>
documen.creatTextNode 创建文本节点
document.body.appendChild(document.createElement("br")); document.body.appendChild(document.createTextNode("子涵真帅"));
标签:body,appendChild,divObj,标签,JavaScript,真帅,document,方法 来源: https://www.cnblogs.com/-0112/p/16028941.html