Check if an element is within a given DOM element