...
Solution Review: Is a Child?
This lesson will explain the solution to the problem in the previous lesson.
Let’s discuss the JavaScript code for isChild.
isChild
function isChild(parent, child){ while(child.parentNode){ if(child.parentNode == parent) return true; else child = child.parentNode } return false}
It takes two parameters, the parent and the child element. First, the function checks if the child has a ...
parent
child