How to hide and show things in jQuery based on the existence of other elements?
<p>I have a form where the jquery validation plugin will generate div tags with the class "error" if there is a validation error on form submission. If any such divs exist I want to display an additional error message above the form. This message is stored like so:</p>

<pre><code>&lt;p class="topError"&gt;Oops errors found!&lt;/p&gt;

&lt;form id="myForm"&gt;

// blah blah

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

<p>if the error divs weren't generated by the plugin, I would do something like:</p>

<pre><code>if (('#myForm div.error').length() &gt; 0 ) {
   $('p.topError').show();
}
</code></pre>

<p>In this situation how can I solve this and I also need the top error to vanish the moment there isn't any error divs in the form.</p>
