-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConceptual.html
More file actions
40 lines (34 loc) · 864 Bytes
/
Conceptual.html
File metadata and controls
40 lines (34 loc) · 864 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>List Item Manipulation</title>
<style>
.highlight {
background-color: yellow;
}
</style>
</head>
<body>
<ul id="myList">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
<script>
let listItems = document.querySelectorAll('#myList li');
listItems.forEach((item, index) => {
console.log('Item ' + (index + 1) + ': ' + item.textContent);
});
listItems.forEach((item, index) => {
if ((index + 1) % 2 === 0) {
item.classList.add('highlight');
}
});
console.log('Total number of list items: ' + listItems.length);
</script>
</body>
</html>