xxxxxxxxxx
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<p>点击按钮创建 p 元素及其内容,并将其添加在文档中。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.createElement("P");
var t = document.createTextNode("这是新增的段落。");
x.appendChild(t);
document.body.appendChild(x);
}
</script>
</body>
</html>