Forest.js Core Documentation - v1.2.3
    Preparing search index...

    Function addEvent

    • addEvent

      Type Parameters

      • E extends Element

        Element type.

      • K extends keyof HTMLElementEventMap

        Event key.

      Parameters

      • type: K

        Event type.

      • handler: (e: HTMLElementEventMap[K] & { currentTarget: E }) => void

        Event handler.

      • Optionaloptions: AddEventListenerOptions

        Event options.

      Returns Utility<E>

      Utility function for adding event listeners.

      Attaches event listeners to an element. Allows specifying event types and handlers.

      const onClick = addEvent("click", (e) => console.log(e.currentTarget))(MyElement);