当前位置:网站首页>节点基础~节点操作
节点基础~节点操作
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,则是深度拷贝,会复制节点本身以及里面所有的子节点。
边栏推荐
- [Valentine's day] - you can change your love and write down your lover's name
- Electronic Association C language level 1 35, bank interest
- Routing decorator of tornado project
- 2022-021ARTS:下半年開始
- tornado之目录
- How to input single quotation marks and double quotation marks in latex?
- leetcode825. Age appropriate friends
- There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
- 【FreeRTOS】FreeRTOS学习笔记(7)— 手写FreeRTOS双向链表/源码分析
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
猜你喜欢

What is the use of cloud redis? How to use cloud redis?
![[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA](/img/71/1d6179921ae84b1ba61ed094e592ff.png)
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA

Splicing plain text into JSON strings - easy language method

The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D

com. alibaba. nacos. api. exception. NacosException

Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement

提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像

Crawler (III) crawling house prices in Tianjin

Knowledge payment applet dream vending machine V2

There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
随机推荐
Uniapp applet subcontracting
MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
Four sets of APIs for queues
Introduction to rce in attack and defense world
JS common time processing functions
响应式移动Web测试题
Experience installing VMware esxi 6.7 under VMware Workstation 16
leetcode825. Age appropriate friends
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty‘
Responsive mobile web test questions
Vulhub vulnerability recurrence 77_ zabbix
在已經知道錶格列勾選一個顯示一列
Zephyr 学习笔记1,threads
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
Solution of running crash caused by node error
How to buy financial products in 2022?
电子协会 C语言 1级 35 、银行利息