This should work:
$(".content").find(" > ul > li > input[type=radio]");
Question
I am using the .find() to find specifiek elements in a div. Now what the .find() does do, is finding every element in that div. I want it only to find it in the first dimension, this means it should not search in div shilds. Now i know there might be a way with :not() as it uses normal selectors.
However, I dont think the .not() is connected with .find(). It doesn't adjust the search function of .find() it only adjusts the selector in the .find() element.
For example:
<div class="content">
<ul>
<li><input type="radio" name="radiobutton_1" value="yes"></li>
<li><input type="radio" name="radiobutton_1" value="no"></li>
</ul>
<ul>
<li><input type="radio" name="radiobutton_2" value="yes"></li>
<li><input type="radio" name="radiobutton_2" value="no"></li>
</ul>
<ul>
<li><input type="radio" name="radiobutton_2" value="yes"></li>
<li><input type="radio" name="radiobutton_2" value="no"></li>
</ul>
<div class="subcontent" style="displaye: none;">
<ul>
<li><input type="radio" name="radiobutton_1_1" value="yes"></li>
<li><input type="radio" name="radiobutton_1_1" value="no"></li>
</ul>
<ul>
<li><input type="radio" name="radiobutton_2_1" value="yes"></li>
<li><input type="radio" name="radiobutton_2_1" value="no"></li>
</ul>
<ul>
<li><input type="radio" name="radiobutton_3_1" value="yes"></li>
<li><input type="radio" name="radiobutton_3_1" value="no"></li>
</ul>
</div>
</div>
In this example in want to search for all radiobuttons, however i dont want to search in the div subcontent.
I've also tryed to check separately if the parrent div is :visible, for some odd reason this didn't work properly. So that's why i'm asking for this.
Hope someone could help me, thanks in advance!
- Nkmol
Solution
OTHER TIPS
try $(div).find(>ul input:radio)