-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnodeList.html
56 lines (46 loc) · 1.2 KB
/
nodeList.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>nodeList</title>
</head>
<body>
<!-- nodeList -->
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<script>
// nodeList
let ulChilds = document.querySelector('ul').childNodes;
//Array.prototype.forEach.call(ulChilds, value => console.log(value))
[].forEach.call(ulChilds, value => console.log(value))
// HTMLCollection
let images = document.images
let embeds = document.embeds
let plugins = document.plugins
let links = document.links
let forms = document.forms
let scripts = document.scripts
let anchors = document.anchors
let applets = document.applets
let children = document.children
// StyleSheetList
let styleSheets = document.styleSheets
let currentScript = document.currentScript
console.log(currentScript)
// DOMTokenList
// Element.prototype.classList
// NamedNodeMap
// Element.prototype.attributes
// DOMStringMap
// HTMLElement.prototype.dataset
// 转成数组
// [...ulChilds].forEach(value => console.log(value))
Array.from(ulChilds).forEach(value => console.log(value));
[].slice.call(ulChilds).forEach(value => console.log(value))
</script>
</body>
</html>