waitForSelector
Wait for an element(s) with a specific selector to appear
API
selector
Type: String | Array
Css selector or an array of selectors
cb
Type: Function
Callback function
options.target
Type: Element
Default: document.body
options.endless
Type: Boolean
Default: false
Sometimes elements can be appended, removed and appended again. This option allows you to track each append of an element into the DOM structure.
options.race
Type: Boolean
Default: false
Wait until one of the given selectros appears in DOM
options.timeout
Type: Number
Default: 0
Stop waiting after this amount of milliseconds.
Calls cb
function with no arguments. Turned off by default.
@return
Returns stop
method
Usage
// Single // Multiple // Race
Changelog
v1.3.0 (2020-02-29):
- moved from
setInterval
toMutationObserver
v1.2.2 (2019-09-14):
delay
option renamed tointerval
- added
timeout
option