当前位置:网站首页>节点基础~节点操作
节点基础~节点操作
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,则是深度拷贝,会复制节点本身以及里面所有的子节点。
边栏推荐
- NLP literature reading summary
- How to buy financial products in 2022?
- 2022 - 021arts: début du deuxième semestre
- There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
- what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
- 果果带你写链表,小学生看了都说好
- 响应式——媒体查询
- The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
- 电子协会 C语言 1级 34 、分段函数
- [untitled] notice on holding "2022 traditional fermented food and modern brewing technology"
猜你喜欢
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
How notepad++ counts words
[MySQL transaction]
Four sets of APIs for queues
There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Introduction to spark core components
tornado项目之路由装饰器
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
随机推荐
Highly paid programmers & interview questions: how does redis of series 119 realize distributed locks?
If there are two sources in the same job, it will be reported that one of the databases cannot be found. Is there a boss to answer
Deep profile data leakage prevention scheme
tornado项目之路由装饰器
Chain ide -- the infrastructure of the metauniverse
【FreeRTOS】FreeRTOS学习笔记(7)— 手写FreeRTOS双向链表/源码分析
What is the use of cloud redis? How to use cloud redis?
leetcode825. Age appropriate friends
在已經知道錶格列勾選一個顯示一列
大厂技术专家:架构设计中常用的思维模型
js 常用时间处理函数
Solution of running crash caused by node error
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
Computer connects raspberry pie remotely through putty
jdbc连接es查询的时候,有遇到下面这种情况的大神嘛?
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
A real penetration test
The IP bound to the socket is inaddr_ The meaning of any htonl (inaddr_any) (0.0.0.0 all addresses, uncertain addresses, arbitrary addresses)
When JDBC connects to es query, is there a God who meets the following situation?
Flink memory model, network buffer, memory tuning, troubleshooting