-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathindex.html
66 lines (50 loc) · 1.08 KB
/
index.html
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
64
65
66
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>auxclick demo</title>
<style>
html {
height: 100%;
overflow: hidden;
}
body {
height: inherit;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
}
button {
border: 0;
background-color: white;
font-size: 10vw;
display: block;
width: 100%;
height: 100%;
}
button {
letter-spacing: 1rem;
}
</style>
</head>
<body>
<button>Click me!</button>
<script>
const button = document.querySelector('button');
const html = document.querySelector('html');
function random(number) {
return Math.floor(Math.random() * number);
}
button.onclick = () => {
const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
button.style.backgroundColor = rndCol;
};
button.onauxclick = (e) => {
e.preventDefault();
const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
button.style.color = rndCol;
}
</script>
</body>
</html>