I need to determine if there is a div with an id below a set parent.
Condition1:
<div id="top">
<div></div>
<div></div>
<div></div>
</div>
Condition2:
<div id="top">
<div></div>
<div id="something"></div>
<div></div>
</div>
I’m trying to know if the element top has any div’s with an assigned id as any child.
I’ve been trying along the lines of the following.
var test = $('#top').find('id');
But I keep getting the same result no matter if there is a div with an id or not.
Any help would be great.
Thanks
Try this:
The
[xx]selector tests for the presence of an attribute xx. What your code does is look for an<id>element.EDIT: You can even be specific as to what kind of tag you want: