jQuery open and close nested ul nav depending on location
<p>I'm making a sub nav in wordpress and have a nested list style menu. An example of the HTML is below. Whichever is the current item has the li class "current_page_item". I need all child menus collapsed unless there is a current_page_item class on the parent or one of the children.</p>

<pre><code>&lt;ul&gt;
 &lt;li class="current_page_item"&gt;&lt;a href="#"&gt;Parent Item&lt;/a&gt;
  &lt;ul class="children"&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#"&gt;Parent Item&lt;/a&gt;
  &lt;ul class="children"&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#"&gt;Parent Item&lt;/a&gt;
  &lt;ul class="children"&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Child page&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
 &lt;/li&gt;
 &lt;li&gt;&lt;a href="#"&gt;Parent Item&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="#"&gt;Parent Item&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>This so far, which works but i wonder if it can be improved as there is some flashing open and then closed again....</p>

<pre><code>jQuery('ul.children').slideUp();
jQuery('li.current_page_item ul.children').slideDown('medium');
jQuery('li.current_page_item').parent().slideDown('medium');
</code></pre>
