当前位置:网站首页>节点基础~节点操作
节点基础~节点操作
2022-07-04 07:18:00 【抱抱旋旋子】
一.创建和添加节点
1.创建节点
document.createElement()方法创建由tagName指定的 HTM元素。因为这些元素原先不存在,是根据我们的需求动态生成的,所以我们也称为动态创建元素节点。
2.添加节点
node.appendchild()方法将一个节点添加到指定父节点的子节点列表末尾。类似于css里面的after伪元素。
node.insertBefore ()方法将一个节点添加到父节点的指定子节点前面。类似于css里面的 before伪元素。
简单版发布留言案例
二.删除节点
node. removechild()方法从DOM中删除一个子节点,返回删除的节点。
删除留言
案例分析:
1.当我们把文本域里面的值赋值给li的时候,多添加一个删除的链接
2.需要把所有的链接获取过来,当我们点击当前的链接的时候,删除当前链接所在的li
3.阻止链接跳转需要添加javascriptvoid(0);或者javascript;
三.复制节点
node.cloneaode(方法返回调用该方法的节点的一个副本。也称为克隆节点/拷贝节点
注意:
1.如果括号参数为空或者为false,则是浅拷贝,即只克隆复制节点本身,不克降里面的子节点
2.如果括号参数为true,则是深度拷贝,会复制节点本身以及里面所有的子节点。
边栏推荐
- "Sword finger offer" 2nd Edition - force button brush question
- what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
- 【网络数据传输】基于FPGA的百兆网/兆网千UDP数据包收发系统开发,PC到FPGA
- uniapp小程序分包
- How to input single quotation marks and double quotation marks in latex?
- The most effective futures trend strategy: futures reverse merchandising
- Responsive - media query
- 用于压缩视频感知增强的多目标网络自适应时空融合
- Check and display one column in the known table column
- NLP-文献阅读总结
猜你喜欢
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
Knowledge payment applet dream vending machine V2
A new understanding of how to encrypt industrial computers: host reinforcement application
The most effective futures trend strategy: futures reverse merchandising
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
Summary of MySQL common judgment functions!! Have you used it
云Redis 有什么用? 云redis怎么用?
Centos8 install mysql 7 unable to start up
Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes
随机推荐
Summary of MySQL common judgment functions!! Have you used it
Responsive - media query
Enter the year, month, and determine the number of days
[FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
Selection (023) - what are the three stages of event propagation?
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
同一个job有两个source就报其中一个数据库找不到,有大佬回答下吗
[FreeRTOS] FreeRTOS learning notes (7) - handwritten FreeRTOS two-way linked list / source code analysis
Solution of running crash caused by node error
Centos8 install mysql 7 unable to start up
Routing decorator of tornado project
大厂技术专家:架构设计中常用的思维模型
2022-021rts: from the second half of the year
Responsive mobile web test questions
How can the old version of commonly used SQL be migrated to the new version?
Electronic Association C language level 1 35, bank interest
Vulhub vulnerability recurrence 76_ XXL-JOB
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
Crawler (III) crawling house prices in Tianjin