JQuery selector for first hierarchy element?
Posted
by Sebastian P.R. Gingter
on Stack Overflow
See other posts from Stack Overflow
or by Sebastian P.R. Gingter
Published on 2010-06-17T14:48:54Z
Indexed on
2010/06/17
14:53 UTC
Read the original article
Hit count: 392
I have this HTML structure:
<div class="start">
<div class="someclass">
<div class="catchme">
<div="nested">
<div class="catchme"> <!-- STOP! no, no catchme's within other catchme's -->
</div>
</div>
</div>
<div class="someclass">
<div class="catchme">
</div>
</div>
</div>
<div class="otherclass">
<div class="catchme">
</div>
</div>
</div>
I am looking for a JQuery structure that returns all catchme's within my 'start' container, except all catchme's that are contained in a found catchme. In fact I only want all 'first-level' catchme's regardless how deep they are in the DOM tree.
This is something near, but not really fine:
var start = $('.start');
// do smething
$('.catchme:first, .catchme:first:parent + .catchme', start)
I sort of want to break further traversing down the tree behind all found elements. Any ideas?
© Stack Overflow or respective owner