"Delete Node"
Steps:
① Find Object
② found his father Parentobj
③parentobj.removechild (Sub-object);
Cases
<! DOCTYPE html>#div1 {width:300px; height:300px; Background:blue; Border-bottom:1px solid black; } </style> <script>functiondel () {varLis = document.getElementsByTagName ("li"); varLastli = lis[lis.length-1]; LastLi.parentNode.removeChild (Lastli); } </script>"Create Node"
Steps:
① creating objects
② find the Parent object Parentobj
③parentobj.addchild (object);
<! DOCTYPE html>#div1 {width:300px; height:300px; Background:blue; Border-bottom:1px solid black; } </style> <script>functionAdd () {//Create an Li varLi = document.createelement ("li"); //Create a text node vartxt = document.createTextNode ("Sea Demon Girl")); //Insert text node to Lili.appendchild (TXT); //insert Li into the ULdocument.getElementsByTagName ("ul") [0].appendchild (LI); } </script>Javascript notes and summaries (2-10) deleting nodes, creating nodes