Debian Codegraph @

good-listener/demo/nodelist.html

raw
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>NodeList</title>
6 </head>
7 <body>
8 <!-- 1. Write some markup -->
9 <button>Click me</button>
10 <button>Click me</button>
11 <button>Click me</button>
12
13 <!-- 2. Include library -->
14 <script src="../dist/good-listener.js"></script>
15
16 <!-- 3. Add listener by passing a list of HTML elements -->
17 <script>
18 var targets = document.querySelectorAll('button');
19
20 listen(targets, 'click', function(e) {
21 console.info(e);
22 });
23 </script>
24 </body>
25 </html>