good-listener

WebJar for good-listener

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

good-listener
Last Version

Last Version

1.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

good-listener
WebJar for good-listener
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/zenorocha/good-listener

Download good-listener

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/good-listener/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>good-listener</artifactId>
    <version>1.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/good-listener/
implementation 'org.webjars.npm:good-listener:1.2.2'
// https://jarcasting.com/artifacts/org.webjars.npm/good-listener/
implementation ("org.webjars.npm:good-listener:1.2.2")
'org.webjars.npm:good-listener:jar:1.2.2'
<dependency org="org.webjars.npm" name="good-listener" rev="1.2.2">
  <artifact name="good-listener" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='good-listener', version='1.2.2')
)
libraryDependencies += "org.webjars.npm" % "good-listener" % "1.2.2"
[org.webjars.npm/good-listener "1.2.2"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : delegate jar [3.1.2,4)

Project Modules

There are no modules declared in this project.

good-listener

Build Status

A more versatile way of adding & removing event listeners.

good listener

Install

You can get it on npm.

npm install good-listener --save

Or bower, too.

bower install good-listener --save

If you're not into package management, just download a ZIP file.

Setup

Node (Browserify)
var listen = require('good-listener');
Browser (Standalone)
<script src="dist/good-listener.js"></script>

Usage

Add an event listener

By passing a string selector (see full demo).

listen('.btn', 'click', function(e) {
    console.log(e);
});

Or by passing a HTML element (see full demo).

var logo = document.getElementById('logo');

listen(logo, 'click', function(e) {
    console.log(e);
});

Or by passing a list of HTML elements (see full demo).

var anchors = document.querySelectorAll('a');

listen(anchors, 'click', function(e) {
    console.log(e);
});

Remove an event listener

By calling the destroy function that returned from previous operation (see full demo).

var listener = listen('.btn', 'click', function(e) {
    console.log(e);
});

listener.destroy();

Browser Support

Chrome logo Edge logo Firefox logo Internet Explorer logo Opera logo Safari logo
Latest Latest Latest 9+ Latest Latest

License

MIT License © Zeno Rocha

Versions

Version
1.2.2
1.2.1
1.2.0
1.1.6