title: jQuery flexible hide/show of fieldsets
body: <p>I want to enhance some fieldsets with the option to show / hide their contents upon clicking their label.</p>
  
  <p>Currently, the HTML looks like this:</p>
  
  <pre><code>&lt;fieldset&gt;
      &lt;legend&gt;Fieldset 1&lt;/legend&gt;
      &lt;!-- Some input, p, div, whatever --&gt;
  &lt;/fieldset&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;Fieldset 2&lt;/legend&gt;
      &lt;!-- Some input, p, div, whatever --&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>So, on click of one <code>fieldset legend</code>, anything but the clicked legend of the parent fieldset should be toggled.</p>
  
  <p>I tried using this:</p>
  
  <pre><code>$("fieldset *:not(legend)").hide();
  $("fieldset legend").click(function(){
      $(this).nextAll().slideToggle();
  });
  </code></pre>
  
  <p>But it doesn't do anything (not even hide the contents in the first place). Of course I want to only toggle the view on the very fieldset the user has clicked, so it has to somehow determine what legend was clicked and then hide the contents of the corresponding fieldsets.</p>
  
  <p>Sure, I could give them all IDs and write the code for every fieldset, but thats rather redundant seeing it would always be the same I think there has to be a way to make this functionality universal for any amount of fieldsets...</p>
  
  <p>Anyone has a neat idea?</p>