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