Skip to content

Commit 883c196

Browse files
committed
Finished Chapter 13 exercise 2
1 parent 3fcd833 commit 883c196

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

ch13exercise2.html

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Chapter 13: Exercise 2</title>
5+
<style>
6+
[data-drop-target] {
7+
height: 400px;
8+
width: 200px;
9+
margin: 2px;
10+
background-color: gainsboro;
11+
float: left;
12+
}
13+
.drag-enter {
14+
border: 2px dashed #000;
15+
}
16+
.box {
17+
width: 200px;
18+
height: 200px;
19+
}
20+
.navy {
21+
background-color: navy;
22+
}
23+
.red {
24+
background-color: red;
25+
}
26+
</style>
27+
</head>
28+
<body>
29+
<h1 id="ad"></h1>
30+
<div data-drop-target="true">
31+
<div id="box1" draggable="true" class="box navy"></div>
32+
<div id="box2" draggable="true" class="box red"></div>
33+
</div>
34+
<div data-drop-target="true"></div>
35+
<script>
36+
var times = localStorage.getItem("ads");
37+
window.onload = () => {
38+
if (isNaN(times)) {
39+
times = 0;
40+
} else {
41+
times = parseInt(times);
42+
}
43+
if (times == 0) {
44+
document.getElementById("ad").innerText = "Bruh get good";
45+
localStorage.ads = times + 1;
46+
} else if (times == 1) {
47+
document.getElementById("ad").innerText = "Sub to me";
48+
localStorage.ads = times + 1;
49+
} else if (times == 2) {
50+
document.getElementById("ad").innerText = "I'm inevitable";
51+
localStorage.ads = times + 1;
52+
} else {
53+
document.getElementById("ad").innerText = "Kazuha moment";
54+
localStorage.ads = 0;
55+
}
56+
};
57+
</script>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)