Check if an element is within the document