<body>
<input type="text" id="num">
<button onclick="add()">添加</button>
<div id="box"></div>
</body>
</html>
<script>
var oX = document.getElementById("num");
var oBox = document.getElementById("box");
function add() {
var oBox1 = document.createElement("div");
if (oX == "") {
alert("请输入内容")
} else {
oBox1.innerHTML = oX.value;
oBox.appendChild(oBox1);
oX.value = "";
}
}
</script>
JavaScript动态节点
最新推荐文章于 2024-11-08 16:09:18 发布