Skip to content

Function: createMutationObserver() ​

ts
function createMutationObserver(
   target, 
   callback, 
   options?): MutationObserver;

Creates a MutationObserver and observes a target element.

Parameters ​

ParameterTypeDescription
targetNodeThe target element.
callbackMutationCallbackThe observer callback.
optionsMutationObserverInitThe observer options.

Returns ​

MutationObserver

The created observer.

Example ​

ts
const el = document.createElement('div')
document.body.appendChild(el)
const obs = createMutationObserver(el, (mutations) => console.log(mutations))
console.log(obs instanceof MutationObserver)

Since ​

1.0.0

Released under the MIT License.