-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay56Domjs.html
34 lines (33 loc) · 1.29 KB
/
Day56Domjs.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Day 56</title>
</head>
<body>
<div>
<ol>
<li>Java</li>
<li>JavaScript</li>
<li>Python</li>
</ol>
</div>
<div>
Hello ,am ponmani
</div>
<script>
for(let i=0;i<document.body.children.length; i++){
console.log(document.body.children[i]);// it will print all the elements inside the body
}
console.log('firstelement child',document.body.firstElementChild);// will print first (div element)
console.log('lastelement child',document.body.lastElementChild);// i will print last (Script element)
console.log('parentelement',document.body.lastElementChild.parentElement);
// accessing the python element
console.log(document.body.firstElementChild.firstElementChild.lastElementChild)// <li>Python</li>
console.log('li parent',document.body.firstElementChild.firstElementChild.lastElementChild.parentElement);
console.log(document.body.firstElementChild.nextElementSibling.previousElementSibling);//first div
console.log(document.location.href);// current website link will be printed
</script>
</body>
</html>