This repository has been archived by the owner on May 28, 2019. It is now read-only.
forked from cferdinandi/events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·92 lines (75 loc) · 2.75 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Events</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- stylesheets -->
<style type="text/css">
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
font-size: 112.5%;
margin-left: auto;
margin-right: auto;
max-width: 40em;
width: 88%;
}
</style>
</head>
<body>
<main>
<nav>
<h1>Events</h1>
<p><a href="https://github.com/cferdinandi/events">GitHub</a></p>
<hr>
</nav>
<section>
<p>
This page has event listeners added for clicks and scrolls. Open up your browser's developer tools and click on the <em>Console</em> tab to see them in action.
</p>
<p>
<button class="btn1">Button 1</button>
<button class="btn2"><span>Button 2</span></button>
<button class="btn3">Button 3</button>
<button class="btn4">Button 4</button>
</p>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
</section>
</main>
<!-- Javascript -->
<script src="dist/events.polyfills.js"></script>
<script>
// Log clicks on elements with the .btn1 class
events.on('click', '.btn1', function (event) {
console.log('.btn1', event.target);
});
// Log clicks on elements with the .btn2 class
// Listen for clicks on elements inside this element, too
events.on('click', '.btn2', function (event) {
console.log('.btn2', event.target);
});
// Listen for all clicks and scrolls
// events.on('click, scroll', window, function (event) {
// // Log the event type and targeted element
// console.log(event.type, event.target);
// });
events.once('click', '.btn3', function (event) {
console.log('clicked: ', event.target);
});
events.once('click', '.btn4', function (event) {
console.log('clicked: ', event.target);
});
</script>
</body>
</html>