Using parentNode instead of parentElement it covers the document case as well. - Node.js DOM

Node.js examples for DOM:Element

Description

Using parentNode instead of parentElement it covers the document case as well.

Demo Code


Util.removeElement = function(element) {
  return element.parentNode.removeChild(element);
};

Related Tutorials