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
Post a Comment