2.1.0 • Published 7 years ago
element-ready-es5 v2.1.0
element-ready-es5
Detect when an element is ready in the DOM
Compatible with browsers like Safari and IE11 (you'll have to polyfill Promise
in IE11)
=======
sindresorhus/master
Install
There is no browser-ready package. You'll need browserify/webpack/rollup.
$ npm install --save element-ready-es5
Usage
var elementReady = require('element-ready-es5');
elementReady('#unicorn').then(function (element) {
console.log(element.id);
//=> 'unicorn'
});
API
elementReady(selector)
Returns a promise for a matching element.
selector
Type: string
elementReadyPromise#cancel()
Type: Function
Stops checking for the element to be ready. The cancelation is synchronous.
Calling it after the promise has settled or multiple times does nothing.
Based on p-cancelable.
Related
- dom-loaded - Check when the DOM is loaded like
DOMContentLoaded
License
MIT © Sindre Sorhus