...

/

Solution Review: Is a Child?

Solution Review: Is a Child?

This lesson will explain the solution to the problem in the previous lesson.

Solution #

Console

Explanation #

Let’s discuss the JavaScript code for isChild.

Press + to interact
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 ...

Access this course and 1400+ top-rated courses and projects.