简体   繁体   中英

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

simply do this :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM