You are here: Reference > JavaScript > client-side > event handling > properties > relatedNode (event)

relatedNode property (event)

Browser support:
9
Returns a reference to the node on which the mutation event occurred.

Syntax:

object.relatedNode;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Retrieves a reference to the node on which the mutation event occurred. For other mutation event types, returns null. For non-mutation events, returns undefined.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the relatedNode property:
<head>
    <script type="text/javascript">
        function Init () {
            if (document.body.addEventListener) {
                document.body.addEventListener ('DOMNodeRemoved', AlertIfModified, false);
            }
        }

        function DelNode () {
            var font = document.getElementById ("myFont");
            if (font) {
                font.parentNode.removeChild (font);
            }
        }

        function AlertIfModified (e) {
            alert ("The node on which the mutation event occurred: " + e.relatedNode);
        }
    </script>
</head>
<body onload="Init ()">
    <font id="myFont">The element to remove from the document body</font>
    <button onclick="DelNode ();">Remove the FONT element from the document!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content