当前位置:网站首页>DOM document
DOM document
2022-06-26 05:34:00 【The simplicity of programmers】
1.DOM It's the document object model (Document Object Model, abbreviation DOM), yes W3C Organization recommended standard programming interface for handling extensible markup language . On the web , Organize pages ( Or document ) Objects are organized in a tree structure , The standard model used to represent objects in a document is called DOM.
DOM Also known as the document tree model

file : A web page can be called a document
node : All content in a web page is a node
Elements : Tags in web pages
attribute : Attributes of the tag
2. Simulate document tree structure

3.DOM Frequent operations
Get elements
Creating elements dynamically
Operate on elements
event
4. Why get page elements
Columns such as : We want to manipulate a part of the page , You need to get the corresponding element of this part first , To operate
according to id Get elements
Get the element from the tag name
according to name Get elements
Get elements by class name
Get elements from selector
5. summary
getElementById()
getElementsByTagName()
getElementsByName()
getElementsByClassName()
querySelector()
querySelectorAll()
6. event
event : Trigger - Response mechanism
Event The interface is represented in DOM Any event that happens in , Some are user generated ( Such as mouse or keyboard events ), And the rest of it is made up of API Generate .
Three elements of the event :
Event source : The element that triggered the event
Event type : How events are triggered
Event handler : The code to execute after the event is triggered
7. Attribute operation
Properties of non form elements
Href、title、id、src、ClassName
Form element properties
value Content retrieval for most form elements (option With the exception of )
type Can get input The type of label ( Input box or check box, etc )
disabled Disable properties
checked Check the box to select Properties
selected Select properties from the drop-down menu
getAttribute() Get in line properties of label
setAttribute() Set label in line properties
removeAttribute() Remove label inline attributes
And element. Attribute distinction : The above three methods are used to obtain any in line attribute .
8. There are three ways to create elements
Document.write()
InnerHTML
Document.createElement()
9. Properties and methods of event objects
event.type Get event type
clientX/clientY All browsers support it , window position
pageX/pageY IE8 I didn't support , Page location
event.target || event.srcElement The element used to get the trigger event
event.preventDefault() Cancel the default behavior
10. Common mouse and keyboard events
onmouseup Triggered when the mouse button is released
onmousedown Press the mouse button to trigger
onmousemove Mouse movement trigger
onkeyup Keyboard key press trigger
onkeydown The keyboard key is lifted to trigger
边栏推荐
- 9 common classes
- AutowiredAnnotationBeanPostProcessor什么时候被实例化的?
- Uni app ceiling fixed style
- Introduction to GUI programming to game practice (I)
- 【MYSQL】MySQL 百万级数据量分页查询方法及其优化
- Supplementary course on basic knowledge of IM development (II): how to design a server-side storage architecture for a large number of image files?
- cartographer_ backend_ constraint
- 国务院发文,完善身份认证、电子印章等应用,加强数字政府建设
- 第九章 设置结构化日志记录(一)
- RIA ideas
猜你喜欢

Could not get unknown property ‘*‘ for SigningConfig container of type org. gradle. api. internal

Recursively traverse directory structure and tree presentation
The wechat team disclosed that the wechat interface is stuck with a super bug "15..." The context of

Leetcode114. Expand binary tree into linked list

Redis usage and memory optimization

基于SDN的DDoS攻击缓解

cartographer_fast_correlative_scan_matcher_2d分支定界粗匹配

cartographer_ fast_ correlative_ scan_ matcher_ 2D branch and bound rough matching

【活动推荐】云原生、产业互联网、低代码、Web3、元宇宙……哪个是 2022 年架构热点?...

Using Jenkins to perform testng+selenium+jsup automated tests and generate extendreport test reports
随机推荐
Uni app ceiling fixed style
自定义WebSerivce作为代理解决SilverLight跨域调用WebService问题
Leetcode114. 二叉树展开为链表
cartographer_ pose_ graph_ 2d
A new journey
CMakeLists. txt Template
Ribbon负载均衡服务调用
Internship May 29, 2019
Pytorch中自己所定义(修改)的模型加载所需部分预训练模型参数并冻结
C# 40. Byte[] to hexadecimal string
Mysql 源码阅读(二)登录连接调试
无线网络存在的安全问题及现代化解决方案
9 common classes
Mise en file d'attente des messages en utilisant jedis Listening redis stream
Use jedis to monitor redis stream to realize message queue function
C XX management system
cartographer_local_trajectory_builder_2d
Red team scoring method statistics
cartographer_ local_ trajectory_ builder_ 2d
Navicat如何将当前连接信息复用另一台电脑