forked from AbeTavarez/Traversing-the-DOM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (36 loc) · 2.09 KB
/
index.js
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
//TODO: 1. Create a variable named (root) and select the html tag from the html file using querySelector
//* add the code here
// console log the root variable
// check the difference between:
// root.children and root.childNodes
// console.log(root);
// console.log(root.children);
// console.log(root.childNodes);
//TODO: 2. Create a variable named (body), using the root array from above assign the body element to the body variable.
//* add the code here
// log the variable (body)
// console.log(body);
//TODO: 3. Create a variable named (h1), using the (body) variable fom above use the property (firstElementChild) to assign the h1 element to the (h1) variable.
//* add the code here
// log the h1 variable to se the result
// console.log(h1);
//TODO: 4. Create a variable named (ul), using the (h1) variable from above use the (nextElementSibling) property to assign the value to the (ul) variable.
//* add the code here
// Log the ul variable to se the result
// console.log(ul);
//TODO: 5. Create a variable named (thirdLi), using the (ul) variable from above use (lastElementChild) property to assign the value to the (thirdLi) variable.
//* add the code here
// Log the text content of the li -> (Third li 🎃)
// console.log(thirdLi.textContent);
//TODO: 6. Create a variable named (secondLi), using the (thirdLi) variable from above use (previousElementSibling) property to assign the value to the (secondLi) variable.
//* add the code here
// Log the text content of the li -> (Second li ⛄)
// console.log(secondLi.textContent);
//TODO: 7. Create a variable named (firstLi), using the (thirdLi) variable from above use (previousElementSibling.previousElementSibling) properties to assign the value to the (firstLi) variable.
//* add the code here
// Log the text content of the li -> (First li 🦁)
// console.log(firstLi.textContent);
//TODO: 8. Finally create a variable named (backToTheUl) using the thirdLi variable from above, use the (parentElement) property to assign th value to the (backToTheUl) variable.
//* add the code here
// Log the backToTheUl -> (ul)
// console.log(backToTheUl);