Skip to content

EventDelegate class to delegate DOM events (with no external dependencies)

Notifications You must be signed in to change notification settings

dot-build/eventdelegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

es-eventdelegate

EventDelegate class to delegate DOM events.

This is the same as the old school jQuery.delegate function, if you are that old, but in a modern ES class way.

Usage

import { EventDelegate } from 'es-eventdelegate';

// attach event handler
const useCapture = true;
const delegate = new EventDelegate(document.body);

// when any link is clicked
delegate.add('click', 'a', eventHandler, useCapture);

// detach a single handler
delegate.remove('click', 'a');

// detach all events
delegate.detach();

About

EventDelegate class to delegate DOM events (with no external dependencies)

Resources

Stars

Watchers

Forks

Packages

No packages published