-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
44 lines (34 loc) · 990 Bytes
/
script.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
'use strict';
// please do not delete the 'use strict' line above
// ランダムに色を出力
const colorList = [
// rgb(239, 208, 224),
"#efd0e0",
"#8ce494",
"#f8bf9f",
"#5edbef",
"#c397f6",
]
document.getElementById('color-button').addEventListener('click', changeColor)
function getRandom(){
const random = Math.floor(Math.random() * colorList.length);
const body = document.getElementsByTagName("body")[0];
body.style.backgroundColor = colorList[random];
const imgArea = document.getElementById("imgArea");
const rndImg = Math.floor(Math.random() * imgs.length);
imgArea.src = imgs[rndImg];
}
function changeColor() {
console.log('Button clicked!'); // feel free to change/delete this line
// document.body.style.backgroundColor = "#efd0e0";
getRandom();
// document.write()
}
const imgs = [
"ゼニガメ.png",
"ヒトカゲ.png",
"フシギダネ.png",
"ワニノコ.png",
"ヒノアラシ.png",
"チコリータ.png",
]