createTextNode() 方法和createTextNode()方法

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>

<p id="demo">单击按钮创建一个标题</p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction(){
var h=document.createElement("H1");
var t=document.createTextNode("Hello World");
h.appendChild(t);
document.body.appendChild(h);
};

</script>

</body>
</html>

document.createElement()    创建元素节点

document.createAttribute()   创建一个属性节点

document.createTextNode() 创建文本节点

1
原文地址:https://www.cnblogs.com/hulaoxi/p/7263040.html