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.
I was working on this problem myself today, here’s what I came up with:
So in your example
you could now find and manipulate the ‘p’ element using
I doubt it will perform well on large structures, but here it is 🙂