<html>
<body>
<div id="div1">
<p id="p1">This is a paragraph.</p>
<p id="p2">This is another paragraph.</p>
</div>
<script>
var para = document.createElement("h1");
var node = document.createTextNode("<h2>This is new.<h2>");
para.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(para);
element.remove();//is it possible to get "element" variable back
</script>
</body>
</html>
答案 0 :(得分:0)
element.style.display=none;
可以通过单击按钮
来完成撤消<button onclick="document.getElementById("div1").style.display=block;">