appendChild = function(message) {
console.log("intercepted!");
}
using the code above does not seem to work.
Anyone knows?
The removeChild() method removes an element's child.
Syntax of JavaScript appendChild:parentNode. appendChild(childNode); The childNode is the node that we want to append to the parent node parentNode . appendChild() will return the appended child.
appendChild() The appendChild() method of the Node interface adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position.
What you might want to replace is Element.prototype.appendChild
but it's probably a bad idea.
This example adds the text intercepted
in the inserted element :
var f = Element.prototype.appendChild;
Element.prototype.appendChild = function(){f.apply(this, arguments);arguments[0].innerHTML="!Intercepted!"; };
document.body.appendChild(document.createElement("div"));
Demonstration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With