-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
66 lines (53 loc) · 1.62 KB
/
app.js
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
//first exercise
document.getElementById("container");
if (container) {
console.log("container found")
} else {
console.log("container not found")
}
//second exercie
let a = document.querySelector("#container")
console.log(a);
//third exercie
let b = document.getElementsByClassName("second")
console.log(b);
//fourth execise
let c = document.querySelector("ol .third");
console.log(c);
//fifth exercise
/* Deviated from shown solution because it was
replacing my text with Hello instead of adding Hello */
let foundDiv = document.querySelector("#container");
foundDiv.innerHTML += "Hello";
//sixth exercise
/* the second solution provided generated the class footermain
as a result of that added some debugging. if(footer) could have
eliminated errors, but could produce undesired results */
let footer = document.querySelector(".footer");
footer.classList.add("main");
let d = footer.className;
console.log(d);
//seventh exercise
footer.classList.remove("main");
let e = footer.className;
console.log(e);
//eighth exercise
let newLi = document.createElement("li");
//ninth exercise
newLi.innerText = "four"
//tenth exercise
let list = document.querySelector("ul");
list.appendChild(newLi);
//eleventh exercise
let liInsideOl = document.querySelectorAll("ol li");
for(let i = 0; i < liInsideOl.length; i++){
liInsideOl[i].style.backgroundColor = "green";
}
//twelveth exercise
/* modified explicit solution to allow for some debugging */
if (footer) {
footer.remove();
console.log("Footer removed.");
} else {
console.log("Footer element not found.");
}