-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass43.html
More file actions
36 lines (31 loc) · 1.02 KB
/
class43.html
File metadata and controls
36 lines (31 loc) · 1.02 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 id="title">Hello, World!</h1>
<h2 class="titlee">first heading using h2</h2>
<h2 class="titlee">second heading using h2</h2>
<h2 class="titlee">third heading using h2</h2>
<p id="para">This is a sample HTML document.</p>
<script>
let headingElement = document.getElementById("title");
let paraElement = document.getElementById("para");
// update h1
headingElement.innerHTML = "Hello, Universe!";
// update paragraph
paraElement.innerHTML = "This is an updated paragraph.";
// select all h2 with class "titlee"
let elements = document.getElementsByClassName("titlee");
// loop through them
for (let i = 0; i < elements.length; i++) {
elements[i].style.color = "green";
elements[i].innerHTML = "Changed heading " + (i + 1);
}
</script>
5
</body>
</html>