forked from eracom/exemples-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flicker.html
57 lines (41 loc) · 1.38 KB
/
flicker.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
<!doctype html>
<html>
<head>
<title>flicker</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, button {
font-family: Roboto, Helvetica, sans-serif;
}
button {
font-size: 200%;
}
</style>
</head>
<body>
<button type="button">Click me</button>
<p>Exemple de bouton qui déclenche une fonction JavaScript.
</p>
<script>
var button = document.querySelector("button");
var body = document.querySelector("body");
button.addEventListener("click", strobo);
var interval = ( 150 );
function strobo() {
setTimeout( function(){
body.style.backgroundColor = "red";
},interval);
setTimeout( function(){
body.style.backgroundColor = "white";
},interval*2);
setTimeout( function(){
body.style.backgroundColor = "red";
},interval*3);
setTimeout( function(){
body.style.backgroundColor = "white";
},interval*4);
}
</script>
</body>
</html>