Retrospring/app/javascript/retrospring/utilities/on.ts

7 lines
229 B
TypeScript
Raw Normal View History

2021-12-24 18:31:30 -08:00
export function on(type: string, selector: string, callback: Function): void {
document.addEventListener(type, (event: Event) => {
if ((event.target as HTMLElement).matches(selector)) {
callback(event);
}
});
};