-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (20 loc) · 714 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (20 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var colors = ['#4fc3f7','#4527a0','#00c853', '#ff7043', '#3d5afe','#b388ff','#ec407a','#f44336','#0097a7', '#1de9b6','#00e676','#c6ff00', '#ffeb3b', '#ffa726', '#ad1457','#607d8b'];
function randoColor(){
var color = colors[Math.floor(Math.random()*colors.length)];;
return color;
}
function changeColor(elem) {
$(elem).css('background-color', randoColor());
return false;
}
$(window).keypress(function(e) {
if (e.keyCode === 0 || e.keyCode === 32) {
location.reload();
}
});
$(document).ready(function(){
for(i = 0; i < 49; i++) {
$('.setting').append('<div onClick="changeColor(this)" class="square" id="div'+ i +'" />');
$('#div'+i).css("background-color", randoColor());
}
});