Check if Element is inside Another Specific Element

0
0

Replace the first selector with the child you are testing and the second selector with the parent you are testing for.

if ( $(".child-element").parents("#main-nav").length == 1 ) { 

   // YES, the child element is inside the parent

} else {
 
   // NO, it is not inside

}
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.