Events API

evt.on()

async

Dynamically enables all events, or specific events passed to it, either globally or for matched DOM elements.

  • Accepts arguments that contain event names as strings or arrays of strings.
    You can pass event names as individual arguments, as an array, or as a string separated by commas or spaces.
    Each value is seen as a new argument.
  • It is not necessary to wait for the method to be executed using await if not needed.
Example:
// Enables all events that have been disabled.
evt.on();

// Enables the events that are passed.
evt.on('click');
evt.on('click', 'resize', 'visible', 'invisible', 'mutation');
evt.on(['click', 'resize', 'visible', 'invisible', 'mutation']);
evt.on('click, resize, visible, invisible, mutation');
evt.on('click resize visible invisible mutation');

// Enables all available events on the <div> element.
$('div').evt.on();

// Enables all available events on all <div> elements.
$('div ?').evt.on();

// Enables the events that are passed on the matched <div> element.
$('div').evt.on('click', 'resize');

// Enables the events that are passed on all <div> elements.
$('div ?').evt.on('click', 'resize');

// Waits for the event listener to be enabled.
await evt.on('click');