-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path109.js
More file actions
63 lines (55 loc) · 1.91 KB
/
Copy path109.js
File metadata and controls
63 lines (55 loc) · 1.91 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
// get multiple elements using getElements by class name
// get multiple elements items using querySelectorAll
// array like object ---> indexing, length property
// let navItems = document.getElementsByTagName("a"); // HTMLCollection
// console.log(navItems);
// we can't use forEach method to iterate through HTMLCollection
// simple for loop
// for of loop
// forEach
// for(let i=0; i< navItems.length; i++){
// // console.log(navItems[i]);
// const navItem = navItems[i];
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// }
// for(let navItem of navItems){
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// }
// navItems = Array.from(navItems);
// console.log(Array.isArray(navItems));
// navItems.forEach((navItem)=>{
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// })
// console.log(Array.isArray(navItems));
// const navItems = document.querySelectorAll(".nav-item"); // NodeList
// console.log(navItems[1]);
// let navItems = document.querySelectorAll("a");
// navItems = Array.from(navItems);
// console.log(Array.isArray(navItems));
// simple for loop
// for of loop
// forEach
// for(let i=0; i< navItems.length; i++){
// // console.log(navItems[i]);
// const navItem = navItems[i];
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// }
// for(let navItem of navItems){
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// }
// navItems.forEach((navItem)=>{
// navItem.style.backgroundColor = "#fff";
// navItem.style.color = "green";
// navItem.style.fontWeight = "bold";
// })
// console.log(navItems);