Jquery find next/prev elements of a certain class but not necessarily siblings

Posted by Gnuffo1 on Stack Overflow See other posts from Stack Overflow or by Gnuffo1
Published on 2009-12-01T16:52:55Z Indexed on 2010/03/29 4:03 UTC
Read the original article Hit count: 319

Filed under:
|
|

The next, prev, nextAll and prevAll methods are very useful, but not if the elements you are trying to find are not in the same parent element. What I want to do is something like this:

<div><span id="click">hello</span></div>
<div><p class="find">world></p></div>

When the span with the id "click" is pressed, I want to match the next element with the class "find", which in this case is not a sibling of the clicked element so next or nextAll won't work.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about selector