// check if element has a child node: const parent = someNode const child = someOtherNode if(parent.contains(child)) { console.log("yes") } else { console.log("no") }