This is a variation of the question asked so many times. For any item, I want to find any other item after it in the entire document. It can be a sibling, but it can be any other element that arises after that. For example, given the following markup,
<div>
<p>Hello</p>
<div>
<p>Foo</p>
<p class="bar">Bar</p>
<p>rawr!</p>
</div>
<p>bop</p>
<input/>
<div>
<p>Another</p>
<div>
<span>something</span>
<p>deep!</p>
</div>
</div>
</div>
<p>last</p>
For this description, let's say the function I'm looking for is called $.fn.nextInDocument. If I called:
$('.bar').nextInDocument('p');
$('.bar').nextInDocument('p').nextInDocument('p');
Continuing, he will receive <p>Another</p>, then, <p>deep!</p>and finally <p>last</p>.
Is there something similar? I don't care if this is a selector or function. I just need functionality.
EDIT The DOM structure has been updated to make it a more complex question, but more understandable for what I'm looking for.