-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
124 lines (100 loc) · 3.22 KB
/
Copy pathtest.html
File metadata and controls
124 lines (100 loc) · 3.22 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM</title>
</head>
<body style="background-color: #212121; color: #fff;">
<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].innerText);
// }
// parent.children[1].style.color = "orange"
// console.log(parent.firstElementChild);
// console.log(parent.lastElementChild);
const dayOne = document.querySelector('.day')
// console.log(dayOne);
// console.log(dayOne.parentElement);
// console.log(dayOne.nextElementSibling);
// console.log("NODES: ", parent.childNodes);
</script>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> DOM </title>
</head>
<body style="background-color: #212121; color: #fff;">
</body>
<script>
const div = document.createElement('div')
console.log(div);
div.className = "main"
div.id = Math.round(Math.random() * 10 + 1)
div.setAttribute("title", "generated title")
div.style.backgroundColor = "green"
div.style.padding = "12px"
// div.innerText = "doc concept"
const addText = document.createTextNode("Doc concept")
div.appendChild(addText)
document.body.appendChild(div)
</script>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM</title>
</head>
<body style="background-color: #212121; color: #fff;">
<ul class="language">
<li>Javascript</li>
</ul>
</body>
<script>
function addLanguage(langName){
const li = document.createElement('li');
li.innerHTML = `${langName}`
document.querySelector('.language').appendChild(li)
}
addLanguage("python")
addLanguage("typescript")
function addOptiLanguage(langName){
const li = document.createElement('li');
li.appendChild(document.createTextNode(langName))
document.querySelector('.language').appendChild(li)
}
addOptiLanguage('html')
// Edit
const secondLang = document.querySelector("li:nth-child(2)")
console.log(secondLang);
//secondLang.innerHTML = "css"
const newli = document.createElement('li')
newli.textContent = "css"
secondLang.replaceWith(newli)
// Edit
const firstLang = document.querySelector("li:first-child")
firstLang.outerHTML = '<li>TypeScript</li>'
// Remove
const lastLang = document.querySelector('li:last-child')
lastLang.remove()
</script>
</html>