JS adds a simple example of removing DIV
function addDiv(w,h){ //If there is the "divCell" layer, deleteDiv() first; //Create a div var my = document.createElement("divCell"); //Add to the page document.body.appendChild(my); //Specify the position of the div through the style. If you want to set the position of the div yourself, this sentence must be. Comment it out and you can know the effect pull~ Try my.style.position="absolute"; //Specify the x coordinate through the style (random number 0~450) my.style.top= Math.round(Math.random()*450); //Specify the y coordinate through the style (random number 0~700) my.style.left= Math.round(Math.random()*700); //Specify width by style my.style.width=w; //Specify height by style my.style.height=h; //Specify background color by style, if the background image is my.style.backgroundImage="url(img/3.jpg)" my.style.backgroundColor="#ffffcc"; //Add div content//my.innerHTML=i++; //Set style transparent my.style.filter = "alpha(opacity=50)"; //Set ID my.id = "divCell"; } function deleteDiv() { var my = document.getElementById("divCell"); if (my != null) my.parentNode.removeChild(my); }The above simple example of adding and deleting DIVs by JS is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.