jQuery find next and prev element
<p>I try to find a <code>next</code> or <code>prev</code> element of current element. But <code>next()</code> and <code>prev()</code> function can only work in a scope, it can not reach outside. For an example this is what I want to achieve:</p>

<pre><code>&lt;ul id="ul1"&gt;
  &lt;li&gt;1&lt;/li&gt;
  &lt;li&gt;2&lt;/li&gt;
  &lt;li&gt;3&lt;/li&gt;
  &lt;li&gt;
    &lt;ul id="ul2"&gt;
      &lt;li&gt;4&lt;/li&gt;
      &lt;li&gt;
        &lt;ul id="ul3"&gt;
          &lt;li&gt;5&lt;/li&gt;
          &lt;li&gt;6&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;7&lt;/li&gt;
      &lt;li&gt;8&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;9&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>If current element is <code>ul1</code>, next element is <code>&lt;li&gt;1&lt;/li&gt;</code>, prev element is null.</p>

<p>If current element is <code>&lt;li&gt;1&lt;/li&gt;</code>, next element is <code>&lt;li&gt;2&lt;/li&gt;</code>, prev element is <code>ul1</code></p>

<p>If current element is <code>&lt;li&gt;8&lt;/li&gt;</code>, next element is <code>&lt;li&gt;9&lt;/li&gt;</code>, prev element is <code>&lt;li&gt;7&lt;/li&gt;</code></p>
