当前位置:网站首页>Webapi collation
Webapi collation
2022-07-26 06:07:00 【Blue lover】
Catalog
WebAPI
DOM: Document object model 、 Operate the elements on the page
BOM: Browser object model 、 Operate browser objects
BOM
window: Top-level object 、 Global object
location、history、navigator、screen、document
location
Address bar object :
attribute :
href: Get or set the address bar address
Method :
reload: Refresh ( Reload the current url)
assign: Load the specified url
replace: Replace url
history
The object of history :
attribute :
length: Number of page history visited
Method :
go: Jump to the specified record ( Parameter is number)
back: Returns the previous in the history
forward: Move forward to the next in history
navigator
Browser object :
attribute :userAgent This attribute can identify the device system and so on
screen
Screen objects
attribute :width、height
window
Top-level object :( Global object )
Method :
alert、confirm、prompt
Timer :1. How often to wait to call
window.setInterval( function , Time )==>window.clearInterval( Timer logo )2. How often is this function called , No more execution after , Recursion can be used to achieve 1
window.setTimeout( function , Time )==>window.clearTimeout( Timer logo )
DOM
Document object model 、 Operate page elements
Access to the node 、 Add the time 、 Attribute operation 、 Node operation
Access to the node
The first group :
id:document.getElementById('id value ');【 What you get is an element 】
tagName:document.getElementsByTagName(' Tag name ')【 Get multiple , Pseudo array 】
The second group :
Selector gets element :
document.querySelector(' Selectors ');// Single
document.querySelectorAll(' Selectors ')// Multiple
Node relationship
Father and son :
Father .children;( Father .childNodes)
Father .firstElementChild、 Father .lastElementChild
Son .parentNodeBrotherhood :
element.nextElementSibling、 // Next element brother
element.previousElemetSibling // The previous element brother
Node properties
nodeType: Node type , Elements ==> 1、 Text ==> 3
nodeName: The name of the node , Elements ==> Capitalized tag names 、 Text node ==> #text
nodeValue: Node values : Elements ==>null、 Text : Text content
Add event
on:
Add event :element.onclick = function () {}
Remove events :element.onclick = null;Event monitoring :
Add event :element.addEventListener(' Event type ', function () {}, Capture );
Remove events :element.removeEventListener(' Event type ', Event handler name ( Function name ));
Operation node
Element attributes :
Get element properties : Elements . attribute (element.id)
Set element properties : Elements . attribute = value ;(element.id = value );
special :class==>className、innerText、innerHTMLStyle attribute :
Set style properties : Elements .style. attribute = value ;(element.style.width = '200px');
Be careful : Don't get what you use for setting 、 Can only get style Inline style , But the general situation is written in css InsideForm Elements :
value attribute :
Get content : Elements .value;(element.value)
Set contents : Elements .value = xxx;(element.value = xxx);
checked attribute :( Single choice, multiple choice )
obtain : Elements .checked;( Boolean value )
Set up : Elements .checked = true/fasle;
disabled attribute :
obtain : Elements .disabled;
Set up : Elements .disabled = Boolean value ;
selected attribute :( The drop-down menu )
obtain : Elements .selected;
Set up : Elements .selected = Boolean valueCustom properties :data-*
H5: Elements .dataset.xxx
obtain : Elements .getAttribute( Property name );
Set up : Elements .setAttribute( Property name , value );
remove : Elements .removeAttribute( Property name );
Node method
Create elements :
The first one is :element.innerHTML = "<div> Content </div>"
The second kind :document.createElement(' Tag name ');Additional elements : Father .appendChild( Son );
Remove elements : Father .removeChild( Son );
Insert elements : Father .inserBefore( new , used ); The new node is inserted in front of the old node
Replacement elements : Father .replaceChild( new , used ) The new node replaces the old node
Clone elements :element.cloneNode( Boolean value );
event
There are a lot of events 、 Different trigger mechanisms
Event type
Mouse events :
click: Click event 、 Click events
dblclick: Double-click the event
mouseenter: Mouse over (mouseover)
mouseleave: Mouse away (mouseout)
mousemove: Mouse movement events
mousedown: The mouse click
mouseup: The mouse is raised
drapover: Drag and drop
drop: ReleaseForm Events :
focus: Focus of attention
blur: Lose focus
input: Input event
change: Change events
submit: Submit the incidentKeyboard events :
keydown: Press the keyboard
keyup: The keyboard is released
keypress: Keyboard input pressLoading event :
load、scroll、resize、beforeunload、DOMContentload
Flow of events
The three stages of an event when it is triggered 、 Capture 、 The goal is 、 Bubbling
Bubbling : After event triggering , Start with the target element 、 Event types will bubble up in turn 、 until document until
Event object
The object generated after the event is triggered :
Event source .addEventListener('click', function (e) {e})
Mouse position :
e.clientX、e.clientY
e.pageX、e.pageY
e.offsetX、e.offsetYKeyboard information :
e.keyCode: Key value
e.altKey: alt keyEvent object properties :
e.target
Event object method :
e.stopPropagation()
e.preventDefault()
Event delegation
Register the events of the child element with the parent element 、 Delegate to the parent element
1、 Register events for the parent element of the descendant element
2、 adopt e.target Get the first triggered element
3、 adopt e.NodeName Check whether it is the element we need
principle : The core principle is to bubble because of events 、 The main point is target
Element size position
offset series :offsetWidth、offsetHeight、offsetLeft、offsetTop
client series :clientWidth、clientHeight
scroll series :scrollTop
getBoundingClientRect: Get the element position size
function
Definition of function :
Name the function :function () {}Anonymous functions :
Self calling function :(function () {})()
Expression function :let fn = function () {}Function call :
Function encountered () Just execute the function ();recursive :
Call the function inside the function
function fn () { fn() }fn();
Be careful : Recursion should have an exit point
Time object
Instantiation :
new Date();
new Date('1999-9-9 6:6:6');
new Date(1999, 9, 9, 6, 6, 6);
new Date(12341232532);
Method :
getFullYear() Get year
getMonth() Get month
getDate() Get date
getHours() For hours
getMinutes() Get minutes
getSeconds() Get seconds
getMilliSeconds() Get milliseconds
getDay() Get week
getTime() Get the timestamp Data.now()
Above get Change it to set、 Is set
Be careful :getDay Can not be set、
Class name operation
class:
obtain : Elements .className
Set up : Elements .className = value ;
classList:
Add the class : Elements .classList.add( Class name );
Delete class : Elements .classList.remove( Class name );
Switch classes : Elements .classList.toggle( Class name );
Find the class : Elements .classList.contans( Class name );
Regular
Match string
establish :
let reg = / Content /;test :
reg.test(str)、reg.exec(str);
Metacharacters :
Border character :^、$
Character set :[a-z]
Quantifier sign :*,+,?,{n},{n,},{n,m}
Predefined classes :\d,\w,\s
All characters :. except \n
Escape character :\.
Modifier :igm
边栏推荐
- Amd zen4 game God u reached 208mb cache within this year, which is unprecedented
- 2022 National latest fire-fighting facility operator (Senior fire-fighting facility operator) simulation test questions and answers
- Sequential search, half search, block search~
- Modifiers should be declared in the correct order 修饰符应按正确的顺序声明
- EM and REM
- Kingbasees SQL language reference manual of Jincang database (6. Expression)
- VRRP protocol and experimental configuration
- Operating steps for uninstalling the mobile app
- Docking wechat payment (II) unified order API
- Viewing the technology stack of distributed system from the crash report of station B
猜你喜欢

2022 National latest fire-fighting facility operator (Senior fire-fighting facility operator) simulation test questions and answers

金仓数据库 KingbaseES SQL 语言参考手册 (6. 表达式)

Kingbasees SQL language reference manual of Jincang database (6. Expression)

【Oracle SQL】计算同比与环比(列转行进行偏移)

招标信息获取

Using easyexcel to import tables to realize batch insertion of xlsx files ----- MySQL of Linux

Understanding the mathematical essence of machine learning

数据库sql语言实战

Benji Banas launched the second season of earn while playing bonus activities, supporting the use of multiple Benji passes!

Introduction of four redis cluster schemes + comparison of advantages and disadvantages
随机推荐
Using easyexcel to import tables to realize batch insertion of xlsx files ----- MySQL of Linux
数据库sql语言实战
Understanding the mathematical essence of machine learning
How can programmers improve mental internal friction?
Matlab 向量与矩阵
[MySQL must know and know] time function number function string function condition judgment
Jincang database kingbasees SQL language reference manual (5. Operators)
Full binary tree / true binary tree / complete binary tree~
CV (1)- Introduction
[SQL optimization] (big table tips) sometimes a 2-hour SQL operation may take only 1 minute
H. Take the Elevator 贪心
VS中使用动态库
“子问题的递归处理”——判断两棵树是不是相同的树——以及 另一颗树的子树
ETCD数据库源码分析——Cluster membership changes日志
Is the transaction in mysql45 isolated or not?
Kingbasees SQL language reference manual of Jincang database (6. Expression)
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(十))
Taobao JD pinduoduo Tiktok taote 1688 and other multi platform commodity app details API interfaces (commodity details page data interface, commodity sales interface, keyword search commodity sales in
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(十一))
Print linked list in reverse order