There are three important methods to search the DOM
elem.matches (CSS) -> To check if elements matches the given CSS selection.
elem.closest (CSS) -> To look for the nearest ancestor that matches the given CSS selector. The elem itself is also checked.
elemA.contains (elemB) -> Returns true if elemB is inside elemA ( a descendant of elemA ) or when elemA == elemB.