-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.js
41 lines (33 loc) · 1022 Bytes
/
animation.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
const alice = document.getElementById("alice");
const drinkShrink = document.getElementById("drink-shrink");
const drinkGrow = document.getElementById("drink-grow");
const room = document.getElementById("room");
document.addEventListener('DOMContentLoaded', function() {
const welcome = document.createElement("h1");
welcome.innerHTML = "Make Alice grow or shrink!";
room.appendChild(welcome);
});
drinkShrink.addEventListener("click", aliceShrink);
function aliceShrink() {
if (alice.className === "alice-m") {
alice.setAttribute("class", "alice-s");
}
else if (alice.className === "alice-l") {
alice.setAttribute("class", "alice-m");
}
else {
return;
}
}
drinkGrow.addEventListener("click", aliceGrow);
function aliceGrow() {
if (alice.className === "alice-m") {
alice.setAttribute("class", "alice-l");
}
else if (alice.className === "alice-s") {
alice.setAttribute("class", "alice-m");
}
else {
return;
}
}