Javascript examples for jQuery Method and Property:jQuery Method Example
jQuery hasDescendant vs hasAncestor
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.6.4.js"></script> <script type="text/javascript"> $(window).load(function(){/*w w w. j a v a 2 s . c o m*/ var a = $('#a'), b = $('#b'); if (a.has(b).length) { console.log('b is inside a'); } else { console.log('b is NOT inside a') } }); </script> </head> <body> <div id="a"> <div id="b"> </div> </div> </body> </html>