[英]how to undo the removed tages by using node.remove() .or is it possible to undo this?
<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>
是的。
element.style.display=none;
可以通過單擊按鈕來撤消
<button onclick="document.getElementById("div1").style.display=block;">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.