Closest previous element with certain ID (with prev())?

Posted by mathon12 on Stack Overflow See other posts from Stack Overflow or by mathon12
Published on 2009-11-21T13:50:12Z Indexed on 2010/03/23 6:03 UTC
Read the original article Hit count: 259

Filed under:
|

I have a big div wit a lot of smaller divs within it. Say,

    <div id="parent">
 <div id="child1">
 </div>
 <div id="child1">
 </div>
 <div id="child2">
 </div>
 <div id="child1">
 </div>
 <div id="child1">
 </div>
</div>

If I'm currently at the last 'child1', how dow I get to the top most child1 with prev()? For me it breaks when it reaches 'child2'.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery