title: Using a variable as jQuery class selector
body: <p>I know that this question was answered multiple times here on stackoverflow, but i just can't get it to work on my problem.</p>
  
  <p>What i want to do is, when a <code>&lt;label&gt;</code> is clicked, check for the labels class and change all matching elements to <code>backgroundColor : #000000</code></p>
  
  <p>Here is my code:</p>
  
  <pre><code>$(function() {
      $('label').click(function(){
          var group = this.className ;
          $('label .'+group).css({
              'backgroundColor'   : '#000000'
          })  ;
      })  ;
  });
  </code></pre>
  
  <p>Unfortunately, this just does nothing. It even throws no error. Where is my fault?</p>
  
  <p><strong>Solution</strong></p>
  
  <p>I had to remove the whitespace in the selector:</p>
  
  <pre><code>$('label.'+group)
  </code></pre>