How javascript deletes the parent node of the current element
This article mainly introduces javascript how to delete the parent node of the current element, the article is very detailed, has a certain reference value, interested friends must read it!
Javascript delete parent node method: 1, through the parentNode attribute to find the parent node and grandfather node; 2, use removeChild () function to delete the parent node, syntax "grandfather node .removeChild (parent node)".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Javascript deletes the parent node of the current element
Find the parent node through parentNode and delete it using removeChild. Just delete the parent node to find one more layer, that is, use Grandpa to delete the father.
/ / delete the method var deleteNode = function (my) {/ / first find the father of the current node var parentNode = m [XSS _ clean]; / / find the grandparent var reprent = parentNode [XSS _ clean]; reprent.removeChild (parentNode);} above is all the content of the article "how to delete the parent node of the current element". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!