JS removeChild () Uso <Body> <P ID = "P1"> Bem-vindo ao <b> javascript </b> mundo! if (node.nodename! = null) {temp+= "nodename ="+node.nodename+"/n"; } else temp+= "nodename = null /n"; if (node.nodetype! = null) {temp+= "nodeType ="+node.nodeType+"/n"; } else temp+= "nodeType = null /n"; if (node.nodEvalue! = null) {temp+= "nodEvalue ="+node.nodEvalue+"/n"; } else temp+= "nodEvalue = null /n"; retornar temp; } var pai = document.getElementById ("p1"); var msg = "nó pai/n"+nodestatus (pai)+"/n"; // retorna o último filho do nó elemento p last = parent.lastChild; msg+= "Antes da exclusão: LastChild-"+nodestatus (last)+"/n"; // exclua o último filho do nó p e se torna B Parent.RemoveChild (Last); last = parent.lastChild; msg+= "Após a exclusão: lastChild-"+nodestatus (last)+"/n"; alerta (msg); -> </script> </body> <html> <head> <title> JS Controla Adicionando e excluindo nós </title> </head> <script type = "text/javascript"> var all; função addParagraph () {all = document.getElementById ("parágrafos"). ChildNodes; var newelement = document.createElement ("p"); var seq = all.length + 1; // Crie um novo atributo var newAttr = document.createattribute ("id"); newAttr.nodEvalue = "p" + seq; newelement.setAttribute (newATTR); // Crie conteúdo de texto var txtNode = document.createTextNode ("parágrafos" + seq); // Adicione o node newelement.appendChild (txtNode); document.getElementById ("parágrafos"). ApndendChild (NewElement); } função delParagraph () {all = document.getElementById ("parágrafos"). ChildNodes; document.getElementById ("parágrafos"). RemoveChild (todos [All.Length -1]); } </script> <yoy> p {background-color: #e6e6e6; } </style> <body> <Center> <input type = "button" value = "adicione nó" onclick = "addParagraph ();"/> <input type = "button" value = "delete node" onclick = "Delparagraph ();"/> <div = "paraGRAPHS"> <p id = "p1" P1 "> </div> </central> </body> </html>O artigo acima "JS Operação Dom" - um exemplo simples de adicionar e excluir nós é todo o conteúdo que compartilho com você. Espero que você possa lhe dar uma referência e espero que você possa apoiar mais o wulin.com.