Function onEvent

  • Bind one or more event handlers directly to an EventTarget.

    Parameters

    • rootTarget: string | EventTarget

      EventTarget or selector

    • eventNames: string
    • handler: EventCallbackType

    Returns void

  • Bind one or more event handlers using event delegation.

    E.g. handle all 'input' events for input and textarea elements of a given form:

    onEvent("#form_1", "input", "input,textarea", function (e: Event) {
    console.log(e.type, e.target);
    });

    Parameters

    • rootTarget: string | EventTarget

      EventTarget or selector

    • eventNames: string
    • selector: string
    • handler: EventCallbackType

    Returns void