当前位置:网站首页>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

边栏推荐
- Making and using of dynamic library (shared library)
- day24 js笔记 2021.09.15
- 合约量化系统开发(搭建讲解)丨合约量化系统开发(源码解析及现成案例)
- Graduated
- Zero foundation self-study SQL course | if function
- Everyone can participate in open source! Here comes the most important developer activity in dragon lizard community
- day31 js笔记 DOM下 2021.09.26
- GCC简介
- 合约量化交易系统开发 | 合约量化APP开发(现成案例)
- day36 js笔记 ECMA6语法 2021.10.09
猜你喜欢

Oracle 日期格式化异常:无效数字

培训通知|2022年境外中资企业机构及人员疫情防控和安全防范专题培训通知

day39 原型鏈及頁面烟花效果 2021.10.13

Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush

2022中国信通院首届业务与应用安全发展论坛成功召开!

JS foundation 3

Web page tips this site is unsafe solution

ThreadLocal的简单理解

day33 js笔记 事件(下)2021.09.28

Zero foundation self-study SQL course | if function
随机推荐
使用 Calendar 计算时间
Jetpack Compose Desktop 桌面版本的打包和发布应用
JS基础2
买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
【sciter】: sciter-fs模块扫描文件API的使用及其注意细节
使用API快捷创建ECS
实体转JSON时,值为null的字段的丢失问题
【SemiDrive源码分析】【X9芯片启动流程】32 - DisPlay模块分析 - RTOS侧
Unity屏幕截图功能
GCC简介
Class pattern and syntax in JS 2021.11.10
随机森林以及 AMR 训练出的诗词制造器
Recommended practice sharing of Zhilian recruitment based on Nebula graph
JS基础5
Compareto() and equals() methods of BigDecimal class
vsftpd服务的部署及优化
js中this的默认指向及如何修改指向 2021.11.09
Packaging and publishing application of jetpack compose desktop version
Thesis reading (59):keyword based diverse image retrieval with variable multiple instance graph
JS基础1-JS引入与运算符