当前位置:网站首页>Day31 JS notes DOM 2021.09.26
Day31 JS notes DOM 2021.09.26
2022-06-28 11:30:00 【Little dream of becoming a big man】
Dom node :
- Elements / Tag node :html All tags below the tag / Elements
- Attribute node : Attributes within the tag
- Text node : All text content in the label
Get child nodes and child element nodes :( When getting child nodes If there is a label, the label will be output Output without label #text)
- childNodes Get all child nodes under the tag
- children Get all the child element nodes under the tag
- firstChild Get the first child node under the tag
- lastChild Get the last child node under the tag
- firstElementChild Get the first child element node under the tag
- lastElementChild Get the last child element node under the tag

Get brother nodes :
- previousSibling Get the last sibling node
- previousElementSibling Get the previous sibling element node
- nextSibling Get the next sibling node
- nextElementSibling Get the next sibling element node
- parentNode Get the parent node
- parentElement Get the parent element node
- attributes Get the properties of the element

Properties of a node :
- nodeType The type of node
- nodeName Node name
- nodeValue The value of the node

Operation node :
- increase document.createElement(' Created tag name ')
- Delete Parent node .removeChild( Deleted child nodes )
- modify Parent node .replaceChild( New nodes , Replaced nodes )
- Insert Parent node .appendChild( Child node )

- In front of a node Parent node .insertBefore( New node , Old node )
- Replication node The node being copied .cloneNode( Parameters )
- Parameter write : true Not only copy the structure You can also copy text content
- Parameters are not written :: Just copy the structure

Get inline style : dom Elements .style. attribute = ' Property value '
Get non inline styles : window.getComputedStyle( Tag element ) - compatible : dom Elements .currentStyle. attribute
Get the offset of the element : The distance between the box element and the upper left of the browser
- offsetLeft Left offset
- offsetTOp The offset at the top
Be careful :
- The distance from the outside of the box to the browser
- margin、 location The size of the will affect ( Floating affects but does not use )
- Displacement does not affect
![]()
Get the size of the element itself :
- offsetWidth/offsetHeight contain content、padding contain border
- clientWidth/clientHeight contain content、padding It doesn't contain border

边栏推荐
- JS基础1-JS引入与运算符
- Wireshark数据抓包分析之FTP协议
- day33 js笔记 事件(下)2021.09.28
- 一套十万级TPS的IM综合消息系统的架构实践与思考
- Excel导入导出便捷工具类
- 买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
- 将浏览器中的文件 url转换为File流
- Everyone can participate in open source! Here comes the most important developer activity in dragon lizard community
- Scientific research - web of science retrieval skills
- Download and install mysql5.7 for windows 10
猜你喜欢

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了

js中的class类模式及语法 2021.11.10

New listing of operation light 3.0 - a sincere work of self subversion across the times!

Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022

day37 js笔记 运动函数 2021.10.11

利用soapUI获取freemarker的ftl文件模板

字符串 & 堆 & 方法区

智联招聘基于 Nebula Graph 的推荐实践分享

Making and using of dynamic library (shared library)
![[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)](/img/e8/21d8d81a3d7b544687d6adc06ad4b1.png)
[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)
随机推荐
功能真花哨,价格真便宜!长安全新SUV真实力到底怎样?
day25 js中的预解析、递归函数、事件 2021.09.16
Making and using of static library
Wireshark数据抓包分析之FTP协议
Cannot redeclare block range variables
MySQL cannot query the maximum value using the max function
New listing of operation light 3.0 - a sincere work of self subversion across the times!
字符串 & 堆 & 方法区
Unity screenshot function
Graduation season, some suggestions for you who are new to the society
day36 js笔记 ECMA6语法 2021.10.09
day37 js笔记 运动函数 2021.10.11
Download and install mysql5.7 for windows 10
工作组环境下的内网渗透:一些基础打法
【无标题】虚拟机vmnet0找不到且报错:没有未桥接的主机网络适配器
QML控件类型:TabBar
近况
一套十万级TPS的IM综合消息系统的架构实践与思考
JS foundation 2
Fancy features and cheap prices! What is the true strength of Changan's new SUV?