Detect when element got some event
$ npm install element-on
or if you use yarn
$ yarn add element-on
const elementOn = require('element-on')
(async () => {
const { element, event } = await elementOn('#pandaDescription', 'DOMContentLoaded')
console.log(element.textContent)
// => Giant pandas have a distinctive black and white coat, ...
console.log(event.type)
// => DOMContentLoaded
})()
Returns a promise for a matching element with targeted event.
Wrapper function of elementOn that pass "load" event as "eventName".
const { elementOnLoad } = require('element-on')
(async () => {
await elementOnLoad(window)
// Do some stuff
})()
Wrapper function of elementOn that pass "DOMContentLoaded" event as "eventName".
Type: string
| Element
| Window
Type: string
Type: Element
The element that's expected to contain a match.
Type: Event
The event that was got.
MIT © Vladimir Skvortsov