-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
63 lines (47 loc) · 1.52 KB
/
index.html
File metadata and controls
63 lines (47 loc) · 1.52 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
62
63
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Random Background Color</title>
<style>
body {
background-color: lightgreen;
}
#button_container {
width: 180px;
margin: 125px auto;
}
#button {
font-size: 1.8em;
text-align: center;
padding: 20px 30px;
background-color: #c6c3fc;
text-decoration: none;
box-shadow: 1px 1px 4px 3px;
}
</style>
</head>
<body>
<div id="button_container">
<a href="#" id="button">Click Me</a>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.js"></script>
<script type="text/javascript">
$(function (){
var button = $('#button_container');
button.on('click', function (e) {
e.preventDefault();
getRandomColor();
});
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * letters.length)];
}
$('body').css('background-color', color);
}
});
</script>
</body>
</html>