Trev
Trev

Reputation: 157

Select only immediate children

I have an arbitrarily deep list

<ul id="tehList">
<li>
  <ul>
  <li></li>
  <li>
    <ul>
    <li></li>
    <li></li>
    </ul> 
  </li>
  <li></li>
  </ul>
</li>
</ul>

I have a jQuery object that references a specific li in this list. For example var tehList = $("#tehList li");

How can I select only the immediate children of tehList?

Thanks!

Travis

Upvotes: 0

Views: 1470

Answers (2)

Prakash
Prakash

Reputation: 6602

simply do this :

$("#tehList li").children();

It'll select only the immediate child of tehlist's li

Upvotes: 4

Quentin
Quentin

Reputation: 943142

#tehList > *

http://www.w3.org/TR/CSS21/selector.html#child-selectors

Upvotes: 7

Related Questions