Verifique se o elemento está dentro de outro elemento específico - CSS-Tricks

Índice

Substitua o primeiro seletor pelo filho que você está testando e o segundo seletor pelo pai que você está testando.

if ( $(".child-element").parents("#main-nav").length == 1 ) ( // YES, the child element is inside the parent ) else ( // NO, it is not inside )

Artigos interessantes...