How to check in Javascript if one element is contained within another

You should use Node.contains, since it’s now standard and available in all browsers.

https://developer.mozilla.org/en-US/docs/Web/API/Node.contains

Leave a Comment