How to check all parents of the div in jquery -


i have code

  <div id="parent">     <div>         <div id="child">        </div>     </div>   </div> 

how can check - there id="child" have parent id="parent" ?

if($("#child").closest("#parent").length) {   // luke, i'm father } 

these should do:

if($("#parent #child").length) {   // noooooooo! } if($("#parent").find("#child").length) {   // may force } if($("#parent:has(#child)").length) {   // powerful jquery selector has become } 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -