Change CSS class based on existence
<p>Firstly I must emphasis that the HTML is pre-generated and cannot be altered - Otherwise I would not be doing it in this way : )</p>

<p>So....</p>

<p>The script and HTML below creates a nice hide/show menu, when you click the navheader the navitem becomes visible.</p>

<p>However I want the css class of the navheader to change based on if navitem is directly below it.</p>

<p>e.g.</p>

<pre><code>navheader (Change Class to linksbelow)
  navitem
navheader (Change Class to NOlinksbelow)
navheader (Change Class to NOlinksbelow)
navheader (Change Class to linksbelow)
  navitem
etc....
</code></pre>

<p>My HTML and JQUERY:</p>

<pre><code>&lt;script&gt;
    $(function() {
      $('.Nav table .navitem').hide();
       $('.Nav table.navheader').click(function() {
        $(this).parent().parent().next().find(".navitem").slideToggle('100');
       });
      });
&lt;/script&gt;

&lt;div class="Nav"&gt;

&lt;table cellpadding="0" cellspacing="0" border="0"&gt;
    &lt;tr&gt;
     &lt;td&gt;
      &lt;table class="navheader"&gt;
       &lt;tr&gt;
        &lt;td&gt;
         &lt;a class="navheader" href="#"&gt;Header Link 1&lt;/a&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
      &lt;/table&gt;
     &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
     &lt;td&gt;
      &lt;table&gt;
       &lt;tr&gt;
        &lt;td&gt;
         &lt;table class="navitem"&gt;
          &lt;tr&gt;
           &lt;td&gt;
            &lt;a class="navitem" href="#"&gt;Link 1&lt;/a&gt;
           &lt;/td&gt;
          &lt;/tr&gt;
         &lt;/table&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
      &lt;/table&gt;
     &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
     &lt;td&gt;
      &lt;table class="navheader"&gt;
       &lt;tr&gt;
        &lt;td&gt;
         &lt;a class="navheader" href="#"&gt;Header link 2&lt;/a&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
      &lt;/table&gt;
     &lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;

&lt;/div&gt;
</code></pre>
