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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -