How to test a DIV to see if it exists
<p>Okay, I'm using Drupal as a CMS for a client, and they have a specific request.  They want a navigation type bar to show up on the left hand side that displays the information about their college programs.  However, if they field doesn't contain any information, they don't want the link to show up.</p>

<p>So, my question is, how would I test the div CLASS to see if it exists, and then show or hide the corresponding link?</p>

<p>Here is my code:</p>

<pre><code>&lt;script&gt;

if ($('.testimonials').length) 
{
    $('#testimon').show();
}
else
{
    $('#testimon').hide();
}   
&lt;/script&gt;
&lt;a href="#" id="descrip"&gt;Program Description&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="admis"&gt;Admission Requirements&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="career"&gt;Career Opportunities&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="co_op"&gt;Co-Op Diploma&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="outcomes"&gt;Program Outcomes&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="struc"&gt;Program Structure&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="testimon"&gt;Student Testimonials&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="transfer"&gt;Transferability&lt;/a&gt;&lt;br /&gt;
&lt;a href="#" id="tuition"&gt;Tuition and Fees&lt;/a&gt;&lt;br /&gt;
</code></pre>

<p>The div I am testing for is given the following class:  <code>&lt;div class="testimonials"&gt;</code></p>

<p>Currently, the "Student Testimonials" contains no information, so the div is actually hidden.  It doesn't even show up if it doesn't contain anything.</p>

<p>Any help would be great, thanks!</p>

<p>EDIT EDIT EDIT</p>

<p>My apologies, the DIV is not hidden, it's just not populated at all.  So, instead of the div showing up, there is actually nothing.  It skips that field, and proceeds on to "Transferability".</p>

<p>EDIT EDIT EDIT</p>

<p>Perhaps it will help if you see the code inside the page:</p>

<pre><code>&lt;div class="main_top"&gt;

  Business Administration - Business
&lt;/div&gt;
&lt;div class="prog_descrip"&gt;
  &lt;label&gt;Program description:&lt;/label&gt;
    ....SOME CODE....
&lt;/div&gt;
&lt;div class="admin_req"&gt;
  &lt;label&gt;Admission Requirements:&lt;/label&gt;
  &lt;div class="ExternalClassF9C2869A55724649B235CB0F312F44EA"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class="career_opp"&gt;
  &lt;label&gt;Career Opportunities:&lt;/label&gt;
  &lt;div class="ExternalClass86EA926232844F31914AB54479958286"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class="co_op_diploma"&gt;
  &lt;label&gt;Co-Op Diploma:&lt;/label&gt;
  &lt;div class="ExternalClass921A20DCA14344B4A5B8C320CBBCCAC2"&gt;
    ....SOME CODE....
   &lt;/div&gt;
&lt;/div&gt;
&lt;div class="prog_out"&gt;
  &lt;label&gt;Program Outcomes:&lt;/label&gt;
  &lt;div class="ExternalClass2964EBDD55244ABDB4DB35FBCC3DF19F"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class="prog_struc"&gt;
  &lt;label&gt;Program Structure:&lt;/label&gt;
  &lt;div class="ExternalClassDE705C7CFB1149ED8C164122009A235E"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class="transfer"&gt;
  &lt;label&gt;Transferability:&lt;/label&gt;
  &lt;div class="ExternalClass7A18D2A8B34D458C89E330E9C6FF4B61"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class="tuition"&gt;
  &lt;label&gt;Tuition And Fees:&lt;/label&gt;
  &lt;div class="ExternalClassC8C745D8B6FA46F9B3E20E6AC95D0933"&gt;
    ....SOME CODE....
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p> </p>
