-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM.html
More file actions
67 lines (64 loc) · 2.16 KB
/
Copy pathDOM.html
File metadata and controls
67 lines (64 loc) · 2.16 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM</title>
<link rel="stylesheet" href="styles/dom.css">
<style>
.big-black p {
color: brown;
}
#list{
color:aquamarine;
}
</style>
</head>
<body>
<div class="big-black">
<h1 class="heading">DOM learning with chai aur code</h1>
<p>DOM stands for Document Object Model. It is a programming interface that represents the structure of a web page, allowing JavaScript to manipulate HTML and CSS dynamically.</p>
</div>
<h1 id="list">List of Foods</h1>
<ul>
<li class="special">Pizza</li>
<li>Burger</li>
<li class="special">Pasta</li>
<li>Sushi</li>
<li class="special">Salad</li>
<li class="special">Fried Rice</li>
<li>Steak</li>
<li class="special">Tacos</li>
<li>Sandwich</li>
<li>Ice Cream</li>
</ul>
<script src="script/dom.js"></script>
<script>
console.log("first lecture on dom");
/* console.log(document.body); */
const student = {
Name: 'Zuthi',
ID: 2103111,
study: function(time) {
console.log(this.Name, time, "Study korse");
}
};
const licollection = document.getElementsByTagName('li');
console.log(licollection);
for(const li of licollection)
{
console.log(li);
}
console.log(document.getElementById('list'));
console.log(document.getElementsByClassName('big-black'));
const place=document.getElementsByClassName('special');
for (const i of place)
console.log(i.innerText);
/* What does document.getElementsByTagName(tagName) do?
- It selects all elements with the specified tag name (e.g., div, p, h1, etc.).
- It returns an HTMLCollection, which is a live collection of all matching elements.
- Since it returns a collection (not a single element),
you need to access elements using indexing ([0], [1], etc.) or loop through them.
*/
</script>
</body>
</html>