当前位置:网站首页>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
边栏推荐
- Gd32f3x0 official PWM drive has a small positive bandwidth (inaccurate timing)
- Apktool tool usage document
- Talk 5 wireless communication
- BOM文档
- Secondary bootloader about boot28 Precautions for ASM application, 28035
- MySQL source code reading (II) login connection debugging
- 二次bootloader关于boot28.asm应用的注意事项,28035的
- Consul服务注册与发现
- [activity recommendation] cloud native, industrial Internet, low code, Web3, metauniverse... Which is the architecture hot spot in 2022
- bingc(继承)
猜你喜欢

Leetcode114. 二叉树展开为链表

Installation and deployment of alluxio

bingc(继承)

Navicat如何将当前连接信息复用另一台电脑

Fedora alicloud source

cartographer_ optimization_ problem_ 2d

【红队】要想加入红队,需要做好哪些准备?

Create SSH key pair configuration steps
![[activity recommendation] cloud native, industrial Internet, low code, Web3, metauniverse... Which is the architecture hot spot in 2022](/img/64/5b2aec7a26c64c104c86e200f83b2d.png)
[activity recommendation] cloud native, industrial Internet, low code, Web3, metauniverse... Which is the architecture hot spot in 2022

cartographer_ pose_ graph_ 2d
随机推荐
A new journey
PHP 2D / multidimensional arrays are sorted in ascending and descending order according to the specified key values
C# 40. Byte[] to hexadecimal string
When was the autowiredannotationbeanpostprocessor instantiated?
睛天霹雳的消息
cartographer_ fast_ correlative_ scan_ matcher_ 2D branch and bound rough matching
Mysql 源码阅读(二)登录连接调试
Win socket programming (Mengxin initial battle)
Daily production training report (15)
Introduction to GUI programming to game practice (I)
What management systems (Updates) for things like this
【红队】要想加入红队,需要做好哪些准备?
cartographer_ local_ trajectory_ builder_ 2d
How to rewrite a pseudo static URL created by zenpart
Leetcode114. 二叉树展开为链表
基于SDN的DDoS攻击缓解
RIA想法
[activity recommendation] cloud native, industrial Internet, low code, Web3, metauniverse... Which is the architecture hot spot in 2022
Ribbon负载均衡服务调用
Supplementary course on basic knowledge of IM development (II): how to design a server-side storage architecture for a large number of image files?