A MutationRecord
represents an individual DOM mutation. It is the object that is inside the array passed to MutationObserver
's callback.
MutationRecord
Properties
Property | Type | Description |
---|---|---|
MutationRecord.type |
String |
Returns "attributes" if the mutation was an attribute mutation,"characterData" if it was a mutation to a CharacterData node,and "childList" if it was a mutation to the tree of nodes. |
MutationRecord.target |
Node |
Returns the node the mutation affected, depending on the MutationRecord.type .For attributes , it is the element whose attribute changed.For characterData , it is the CharacterData node.For childList , it is the node whose children changed. |
MutationRecord.addedNodes |
NodeList |
Return the nodes added. Will be an empty NodeList if no nodes were added. |
MutationRecord.removedNodes |
NodeList |
Return the nodes removed. Will be an empty NodeList if no nodes were removed. |
MutationRecord.previousSibling |
Node |
Return the previous sibling of the added or removed nodes, or null . |
MutationRecord.nextSibling |
Node |
Return the next sibling of the added or removed nodes, or null . |
MutationRecord.attributeName |
String |
Returns the local name of the changed attribute, or null . |
MutationRecord.attributeNamespace |
String |
Returns the namespace of the changed attribute, or null . |
MutationRecord.oldValue |
String |
The return value depends on the Note: For this to work as expected, |
Specifications
Specification |
---|
DOM Standard # interface-mutationrecord |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
MutationRecord |
16
|
12
|
14
|
11
|
15
|
7
|
4.4
|
25
|
14
|
14
|
7
|
1.5
|
addedNodes |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
attributeName |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
attributeNamespace |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
nextSibling |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
oldValue |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
previousSibling |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
removedNodes |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
target |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
type |
16
|
12
|
14
|
11
|
15
|
7
|
≤37
|
25
|
14
|
14
|
7
|
1.5
|
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord