- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_children.js
More file actions
Latest commit
25 lines (21 loc) · 625 Bytes
/
Copy path05_children.js
File metadata and controls
25 lines (21 loc) · 625 Bytes
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
// children
// childNodes - return all childNodes including whitespaces
// which is treated as text node
// children
// firstChild
// lastChild
// CHILD
constchild=document.querySelector('#shp');
//total 9 cz with white space
console.log(child.childNodes);
//total 4 li#member cz without space just element child
// following all child in #shp :
console.log(child.children);
// example u should use child.children
constallChild=[...child.children];
allChild.forEach(function(items){
items.style.background='blue';
});
// first-child and last-child
console.log(child.firstChild);
console.log(child.lastChild);