title: jquery select elements by class using name from variable
body: <p>I want to do somethings in jQuery to all the elements which match on a certain class name. The class name comes from a variable. How do I do the select using by class using my variable?</p>
  
  <pre><code>var x = $(this).attr('href').slice(1);
  </code></pre>
  
  <p>this will set <code>x</code> equal to the name of the <code>class</code> I want.</p>
  
  <p>now I want to select all the elements with that class name</p>
  
  <p>I try stuff like this but it doesn't work</p>
  
  <pre><code>$(.x.show().addClass('active').siblings().hide().removeClass('active');
  </code></pre>
  
  <p>basic basically I want affect all the elements with where <code>class = x</code></p>
  
  <p>Finally, instead of setting <code>x</code> to the class name, can I just get my <code>array</code> of classes in the first variable assignment?</p>
  
  <p>i.e. instead of </p>
  
  <pre><code>var x = $(this).attr('href').slice(1);
  </code></pre>
  
  <p>can I do this [pseudo code]: </p>
  
  <pre><code>var x = classname is $(this).attr('href').slice(1);
  </code></pre>