当前位置:网站首页>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
边栏推荐
- day25 js中的预解析、递归函数、事件 2021.09.16
- Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
- Cannot redeclare block range variables
- Lihongyi, machine learning 7 Conclusion
- 智联招聘基于 Nebula Graph 的推荐实践分享
- Docker modifies the user name and password of MySQL
- 东方财富手机股票开户哪个券商更安全更方便?
- day39 原型鏈及頁面烟花效果 2021.10.13
- SQL中的DQL、DML、DDL和DCL是怎么区分和定义的
- 功能真花哨,价格真便宜!长安全新SUV真实力到底怎样?
猜你喜欢
js中的class类模式及语法 2021.11.10
零基础自学SQL课程 | IF函数
人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了
Day39 prototype chain and page Fireworks Effect 2021.10.13
Fancy features and cheap prices! What is the true strength of Changan's new SUV?
QML控件类型:TabBar
Jetpack Compose Desktop 桌面版本的打包和发布应用
Blue Bridge Cup Maze (dfs+ backtracking)
Making and using of static library
字符串 & 堆 & 方法区
随机推荐
Wireshark数据抓包分析之FTP协议
将浏览器中的文件 url转换为File流
Analyze whether there is duplicate data in the list and repeat it several times
Redis6 一:Nosql引入、Redis可以解决什么问题?
JS基础5
BigDecimal 类的 compareTo() 和 equals()方法
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作!
JS foundation 4
Unity屏幕截图功能
This Exception was thrown from a job compiled with Burst, which has limited exception support. report errors
拼接String集合中的字符串_基于Stream
【SemiDrive源码分析】【X9芯片启动流程】32 - DisPlay模块分析 - RTOS侧
It is safer for individuals to choose which securities company to open an account for buying floor funds
Unity screenshot function
mysql-. SQL file phishing Online
[semidrive source code analysis] [x9 chip startup process] 32 - play module analysis - RTOS side
js中this的默认指向及如何修改指向 2021.11.09
工作组环境下的内网渗透:一些基础打法
day29 js笔记 2021.09.23
Everyone can participate in open source! Here comes the most important developer activity in dragon lizard community