当前位置:网站首页>Node foundation ~ node operation

Node foundation ~ node operation

2022-07-04 07:21:00 Hugging spinner

One . Create and add nodes

1. Create nodes  

document.createElement() Method created by tagName designated HTM Elements . Because these elements didn't exist , It's dynamically generated according to our needs , So we also call it dynamic creation of element nodes . 

2. Add a node

 node.appendchild() Method to add a node to the list of child nodes of the specified parent node At the end of . Be similar to css Inside after Pseudo elements .

node.insertBefore () Method to add a node to the specified child node of the parent node front . Be similar to css Inside before Pseudo elements .


Simple version release message case

Two . Delete node

node. removechild() Methods from DOM Delete a child node in the , Return the deleted node .
 

Delete message

case analysis :

1. When we assign the value in the text field to li When , Add one more deleted link
2. You need to get all the links , When we click on the current link , Delete the current link li
3. To prevent link jump, you need to add javascriptvoid(0); perhaps javascript;

3、 ... and . Replication node

 node.cloneaode( Method returns a copy of the node that called the method . Also known as clone nodes / Copy node

  Be careful :

1. If the bracket parameter is Empty or empty false, It's a light copy , That is, only clone the replication node itself , You can't lower the child nodes inside

2. If the bracket parameter is true, It is Deep copy , It will copy the node itself and all its children .


 


 

原网站

版权声明
本文为[Hugging spinner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207040717430775.html