<div id="div">
<div> <!-- first level -->
<div> <!-- second level -->
<div>1.1</div> <!-- third level -->
<div>1.2</div>
</div>
<div>
<div></div>
<div>2.2</div>
</div>
</div>
</div>
What are the jQuery selector expressions for selecting the followings:
1. div commented by first level
2. divs commented by second level
3. divs commented by third level
The key to all of these is either the
>(child) selector or thechildren()method.First level:
Second level:
Third level:
If you’re not interested in a particular tag (eg div) then simply don’t specify a selector to
children(). For example, all second level elements: