-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathturtle.html
More file actions
61 lines (53 loc) · 1.35 KB
/
turtle.html
File metadata and controls
61 lines (53 loc) · 1.35 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Turtle Maker</title>
<style>
* {
padding: 0px;
margin: 0px;
}
body{width:100%;}
#main{
width:300px;
margin: 100px auto;
}
#main i {
display: inline-block;
width: 5px;
height: 5px;
background-color: black;
float: left;
}
#main i:hover{
background-color: gray;cursor: pointer;
}
</style>
</head>
<body>
<div id="main">
</div>
<script>
(function () {
let m = document.getElementById("main");
let htmlString = [];
for (let i = 0; i < 4020; i++) {
htmlString.push(`<i></i>`);
}
m.innerHTML = htmlString.join("");
let is = document.getElementsByTagName("i");
[...is].forEach((i)=>{
i.onclick=function(){
let curColor = i.style.backgroundColor;
if(curColor == "black" || curColor == ""){
i.style.backgroundColor = "white";
}else{
i.style.backgroundColor = "black";
}
}
})
})();
</script>
</body>
</html>