Você pode alterar dinamicamente elementos em HTML através de JavaScript
Adicione elementos ao HTML
Primeiro, você precisa criar uma tag e adicionar o conteúdo correspondente à tag e adicione a tag criada ao local correspondente.
<! xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> Documento de teste </title> <script = "text = jav"/jav "/jav"/jav)/html; charset = gb2312 "/> <title> Documento de teste </title> <script =" text/jav "/jav"/jav "/jav"/jav) document.createElement ("p"); var node = document.createTextNode ("Adicione novo parágrafo"); element.appendChild (nó); x = document.getElementById ("Demo"); X.AppendChild (elemento); } </script> </head> <body> <div id = "Demo"> <p> Este é o primeiro parágrafo </p> </div> <input type = "button" value = "button" onclick = "add ()"/> </body> </html>Exclua um elemento em html
<! xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> funt. document.getElementById ("Demo"); var filho = document.getElementById ("p1"); padre.RemoveChild (criança); } </sCript> </head> <body> <div id = "Demo"> <p id = "p1"> Este é o primeiro parágrafo </p> <p id = "p2"> este é o segundo parágrafo </p> </div> <input type = "buttle" = "Delete" OnClick = "Deletee ()"/>