-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut15.js
More file actions
61 lines (35 loc) · 1.26 KB
/
tut15.js
File metadata and controls
61 lines (35 loc) · 1.26 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
let emt = document.querySelector('.p-2');
console.log(emt);
emt = document.querySelector('.container');
// console.log(emt);
console.log(emt.childNodes); // print Nodelist including hidden text, comments, newline
console.log(emt.children); // print Nodelist of only elements without hidden text, comments, newline
let nodename = emt.childNodes[0].nodeName;
console.log(nodename);
let nodename2 = emt.children[1].nodeName;
console.log(nodename2);
/*
Node Type:
1 = element
2 = attribute
3 = text node
8 = comments
9 = document
10 = docType
*/
let nodetype = emt.childNodes[0].nodeType;
console.log(nodetype)
let nodetype2 = emt.children[1].nodeType
console.log(nodetype2);
let ctr = document.querySelector('div.container');
console.log(ctr);
console.log(ctr.children[0].children[0].getElementsByClassName('card-header')[0].innerText);
console.log(ctr.firstChild);
console.log(ctr.firstElementChild);
console.log(ctr.lastChild);
console.log(ctr.lastElementChild);
console.log(ctr.children);
console.log(ctr.childElementCount);
console.log(ctr.firstElementChild.parentNode);
console.log(ctr.firstElementChild.nextElementSibling);
console.log(ctr.firstElementChild.nextElementSibling.nextElementSibling);