title: This jQuery toggleClass behaviour seems strange, am I doing this correctly?
body: <p>I have a CSS rule for hiding elements with a class="hidden" and I'm using jQuery to toggle this class on and off on whatever ID i click on so I can make elements disappear.</p>
  
  <p>Why does this not work?</p>
  
  <pre><code>$(this).attr('id').toggleClass("hidden");
  </code></pre>
  
  <p>but this does?</p>
  
  <pre><code>var x = "#" + $(this).attr('id');
  $(x).toggleClass("hidden");
  </code></pre>
  
  <p>I know that the id is being taken correctly on the first example, but it seems that to toggle the class I have to add a "#".  I haven't seen any examples of others having to resort to this so I'm wondering what madness I have here.</p>
  
  <p>Many thanks</p>