-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwo.html
More file actions
44 lines (35 loc) · 1.15 KB
/
two.html
File metadata and controls
44 lines (35 loc) · 1.15 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM | Raj Shekhar</title>
</head>
<body style="background-color:#212121;color:white">
<div class="parent">
<div class="day">Monday</div>
<div class="day">Tuesday</div>
<div class="day">Wednesday</div>
<div class="day">Thursday</div>
</div>
</body>
<script>
const parent=document.querySelector(".parent")
// console.log(parent);
// console.log(parent.children);
// console.log(parent.children[1].innerHTML);
// for (let i = 0; i < parent.children.length; i++) {
// console.log(parent.children[i].innerHTML)
//
// }
// console.log(parent.firstElementChild); // to get the first child element of parent
// console.log(parent.lastElementChild); // to get the last element child
parent.children[2].style.color="green";
const dayOne=document.querySelector('.day')
console.log(dayOne);
console.log(dayOne.parentElement); // to find parent Element of child.
console.log(dayOne.nextElementSibling); // to find the next sibling element
//*** IMPORTANT
//Here line break is also a node element.
console.log("NODES: ",parent.childNodes);
</script>
</html>