Reputation: 3554
Given the following HTML, how can I select all of the 1st-generation UL tags such that I end up with the following elements: company, subnav_1 - subnav_4, enginTool, prodSup, qualRel and lit, but none of the ULs inside of those elements?
<div id="col1">
<h2></h2>
<ul id="company"></ul>
<div id="nav">
<div id="navcordion">
<h2></h2>
<div>
<ul id="subnav_1">
<li>
<ul></ul>
</li>
</ul>
</div>
<h2></h2>
<div>
<ul id="subnav_2">
<li>
<ul></ul>
</li>
</ul>
</div>
<h2></h2>
<div>
<ul id="subnav_3">
<li>
<ul></ul>
</li>
</ul>
</div>
<h2></h2>
<div>
<ul id="subnav_4"></ul>
</div>
</div>
<div class="clear"></div>
</div>
<h2></h2>
<h2></h2>
<ul id="enginTool"></ul>
<h2></h2>
<ul id="prodSup"></ul>
<h2></h2>
<ul id="qualRel"></ul>
<h2></h2>
<h2></h2>
<h2></h2>
<ul id="lit"></ul>
<h2></h2>
</div>
I've tried #col1>ul
, #col1 ul:first
and #col1 ul:nth-child(1)
, but neither gives me all of the elements I'm after.
Upvotes: 0
Views: 201
Reputation: 723448
Since the <ul>
s are only either in <li>
s or <div>
s, would this work? Only selects <ul>
s that are children of <div>
s.
div > ul
Using jQuery you should be able to filter by passing in the parent of #col1
as the second argument to $()
so you don't accidentally select other lists.
Upvotes: 3