How can I check if one DOM element is a child of another DOM element? Are there any built in methods for this? For example, something like:
If not then any ideas how to do this? It also needs to be cross browser. I should also mention that the child could be nested many levels below the parent.
Another solution that wasn’t mentioned:
It doesn’t matter whether the element is a direct child, it will work at any depth.
Alternatively, using the