- if ( $(".child-element").parents("#main-nav").length == 1 ) {
- // YES, the child element is inside the parent
- } else {
- // NO, it is not inside
- }
- //该片段来自于http://www.codesnippet.cn/detail/221020136557.html
来源: http://www.codesnippet.cn/detail/221020136557.html