Get the closest element matching a selector