当前位置:网站首页>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中this的默认指向及如何修改指向 2021.11.09

Redis6 1: what problems can be solved by the introduction of NoSQL and redis?
This Exception was thrown from a job compiled with Burst, which has limited exception support. report errors

js中的数组方法 2021.09.18
![[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)

QML控件类型:TabBar

day34 js笔记 正则表达式 2021.09.29

Word、PDF、TXT文件实现全文内容检索需要用什么方法?

携手Cigent:群联为SSD主控固件引入高级网络安全防护特性
随机推荐
Download and install mysql5.7 for windows 10
Recommended practice sharing of Zhilian recruitment based on Nebula graph
[semidrive source code analysis] [x9 chip startup process] 32 - play module analysis - RTOS side
使用ssm项目对Mysql8进行访问的时候,出现连接失败和一些错误的解决办法
Characteristics of solar wireless LED display
js中的数组方法 2021.09.18
基于验证码识别的机器学习项目captcha_trainer操作实践
BigDecimal 类的 compareTo() 和 equals()方法
day36 js笔记 ECMA6语法 2021.10.09
day34 js笔记 正则表达式 2021.09.29
Packaging and publishing application of jetpack compose desktop version
使用API快捷创建ECS
Basic 02: variable, remember the mobile number of the object
Graduated
Wealth management for programmers
Makefile简介
day33 js笔记 事件(下)2021.09.28
动态库(共享库)的制作和使用
day31 js笔记 DOM下 2021.09.26
工作组环境下的内网渗透:一些基础打法