一言不合上代码,以canvas为例:

id = "canvas1";

//创建一个canvas
var canvas = document.createElement("canvas");
canvas.id = id;
canvas.width = window.screen.availWidth;
canvas.height= window.screen.availHeight;
canvas.style.cssText = "position: absolute; left: 0px; top: 0px;pointer-events: none;";

document.body.appendChild(canvas);

var ctx = canvas.getContext("2d");

//删除它
var self = document.getElementById(id);
var parent = self.parentElement;
parent.removeChild(self);
//document.body.removeChld(self) 应该也可以

有关删除一个dom,原生js的例子,网络上充斥着一大抄:

var list=document.getElementById("myList");
list.removeChild(list.childNodes[0]);

这种例子有什么意义?