当前位置:网站首页>Related concepts and operations of DOM model
Related concepts and operations of DOM model
2022-07-28 05:51:00 【Still love me】
DOM Basic concepts
Document object model (DOM,Document Object Model) Is aimed at XML But extended to HTML Application programming interface for (API,Application Programming Interface)
DOM Display and operation HTML and XML The basis of document content API, among Document -- XML file or HTML file ;Object -- Object Properties and methods of objects ;Model -- Model Model ,DOM Is aimed at XML or HTML Based on tree structure API
according to W3C DOM standard ,DOM It's a browser , platform , Language independent interfaces , It allows us to access other standard components of the page
DOM Map the whole page to a multi-layer node structure ,HTML or XML Each component of the page is a node of some kind , These nodes contain different types of data .

Core DOM The operation of
Look at the node
getElementById(); By element id Value to view
getElementsByName(); Of the query element name attribute
getElementByTagName(); Returns a collection of objects with the specified label name
The parent node finds the child node
Find child node objects through parent node objects ( There may be text nodes ) Compatibility is good.
Parent node object .firstChild Find the first child node under the parent node
Parent node object .lastChild Find the last child node under the parent node
Parent node object .childNodes Multiple Find all child nodes under the parent node
Find the child element node object through the parent node object
Parent node object .firstElementChild Find the first child element node under the parent node
Parent node object .lastElementChild Find the last child element node under the parent node
Parent node object .children Multiple Find all child element nodes under the parent node
The child node finds the parent node
Child node object .parentNode Find the parent node through the child node
Child node object .parentElement Find parent elements through child nodes
Search between brothers
.nextSibling Find the next sibling May be text
.nextElementSibling Find the next element sibling node
.previousSibling Find the last sibling May be text
.previousElementSibling Find the sibling node of the previous element
Node object
Node object .getAttribute(" Property name ") Get the property value according to the property name
Node object .setAttribute(" Property name "," Property value ")
Node object .removeAttribute(" Property name ") Delete the corresponding pair of genera
边栏推荐
猜你喜欢
随机推荐
Review of metallurgical physical chemistry -- Fundamentals of metallurgical reaction kinetics and characteristics of multiphase reaction kinetics
media-搭建直播服务器
cmd和npm基础命令
Example of MySQL processing legacy data
蓝桥代码 翻硬币(我这样写也通过了,官网测试是不是有问题)
微信公众号-授权登录
书籍-社会性动物
MYSQL之搭建数据库系列(一)——下载MYSQL
DOM——页面的渲染、style属性操作、预加载与懒加载、防抖与节流
Child parent thread interaction
标准C语言总结4
结果填空 凑算式(DFS*C语言)
在线词云图生成(以WordArt为例)
(php毕业设计)基于php校园网络报修管理系统获取
结果填空 国庆有几天是星期日(纯Excel解决)
基于XMind的E-R图制作
结果填空 马虎的算式(暴力解决)
js中==和===区别
Global event bus
书籍-穷查理宝典









