-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM-jQuery.txt
More file actions
95 lines (82 loc) · 1.58 KB
/
DOM-jQuery.txt
File metadata and controls
95 lines (82 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
1. Browser Object
var window = {
innerWidth:
innerHeight:
outerWidth:
outerHeight:
};
var navigator = { //easy to modify by user
appName:
appVersion:
language:
platform:
userAgent:
};
var width = window.innerWdith ||document.body.clientWidth;
var screen = {
width:
height:
colorDepth:
};
var location = {
href:
protocol:
host:
port:
pathname:
search:
hash:
assign: function () {}, //reload new page
reload: function () {} //refresh
};
var document = {
title:
cookie: //server use httpOnly
getElementById: function () {},
getElementByTagName: function () {}
};
var history = { //don't use
back: function () {},
forward: function () {}
};
2. DOM Operation
get element (node):
document.getElementByClassName()
document.getElementById()
document.getElementByTagName()
document.querySelector()
document.querySelectorAll()
document.creatElement()
update element:
e.innerHTML
e.innerText
e.textContent
e.style
e.style.color
...
insert element:
e.appendChild()
e.insertBefore(newElement, referenceElement)
delete element:
e.removeChild()
3. Form Operation
form element:
<input type="text">
<input type="password">
<input type="radio">
<input type="checkbox">
<select>
<input type="hidden">
<input type="date">
<input type="datetime">
<input type="datetime-local">
<input type="color">
get value of element:
e.value
e.checked //radio checkbox
submit form:
request = new XMLHttpRequest();
request = new ActiveXObject('Microsoft.XMLHttp';
4. File Upload
<input type="file"> //enctype = multipart/form-data, method = post
5. jQuery