Skip to content

Commit 161c27d

Browse files
committed
Parents and the Siblings of the Document
1 parent 03185e6 commit 161c27d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Chapter 7/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
<body>
1212
<div>
13-
<p>This is me and I am great!</p>
14-
<span>Sibling</span>
13+
<div class="first">First</div>
14+
<div class="second">Second</div>
1515
</div>
1616
<script src="script.js"></script>
1717

Chapter 7/script.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
//31 Walking the DOM
22

3+
/*
34
//32 Children of an element
45
console.log(document.body.firstChild)
56
console.log(document.body.lastChild)
67
// console.log(document.body.childNodes) //This will not array, they are nodes
78
let arr = Array.from(document.body.childNodes)
8-
console.log(arr)
9+
console.log(arr)
10+
*/
11+
12+
// 33 Parents and Siblings
13+
console.log(document.body.firstChild)
14+
a = document.body.firstChild
15+
console.log(a.parentNode)
16+
console.log(a.parentElement)
17+
console.log(a.firstChild.nextSibling)

0 commit comments

Comments
 (0)