Is $.contains() what you want?
jQuery.contains( container, contained )
The
$.contains()method returns true if the DOM element provided by the second argument is a descendant of the DOM element provided by the first argument, whether it is a direct child or nested more deeply. Otherwise, it returns false. Only element nodes are supported; if the second argument is a text or comment node,$.contains()will return false.
Note: The first argument must be a DOM element, not a jQuery object or plain JavaScript object.