Select next element in the page source using jQuery

Posted by Travis on Stack Overflow See other posts from Stack Overflow or by Travis
Published on 2010-05-28T19:09:35Z Indexed on 2010/05/28 19:12 UTC
Read the original article Hit count: 199

Filed under:
|

I have an arbitrarily deep list of the form:

<ul>
 <li></li>
 <li>
  <ul>
   <li></li>
  </ul>
 </li>
</ul>

I am trying to build a function "nextElement" that returns a jQuery selector.

The first time the function is called, it returns the first li in the list. The second time it is called, it returns the next li in the page. Etc.

I'd like this function to pay no attention to siblings, parents, children, etc. All I care about is that everytime it is called, the next li in the source gets chosen.

Any suggestions on how to go about approaching this?

Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery