title: Javascript filter visibility of html elements using radio buttons
body: <p>I've seen many examples of filtering with checkboxes and radio buttons to display different classes. Problem is for two selected classes all elements with either class will show but I'd like it to only show elements with BOTH classes. Here is some sample code: <a href="http://jsfiddle.net/DH3m3/" rel="nofollow">http://jsfiddle.net/DH3m3/</a></p>
  
  <p>the js:</p>
  
  <pre><code>function filterItems() {
      var colors = $(":radio:checked").map( function(){ return this.value; }).get();
      var goodClasses = colors.join(",");
      $(".item").hide().filter(goodClasses).show();
  }
  
  filterItems();
  
  $(":radio").change(filterItems);
  </code></pre>
  
  <p>and the html:</p>
  
  <pre><code>&lt;label for="one"&gt;one&lt;/label&gt;&lt;input id="one" type="radio" name="number" value=".one" /&gt;
  &lt;label for="two"&gt;two&lt;/label&gt;&lt;input id="two" type="radio" name="number" value=".two" /&gt;
  &lt;label for="none"&gt;none&lt;/label&gt;&lt;input id="none" type="radio" name="number" value=".none" /&gt;
  &lt;hr/&gt;
  &lt;label for="red"&gt;red&lt;/label&gt;&lt;input id="red" type="radio" name="color" value=".red" /&gt;
  &lt;label for="blue"&gt;blue&lt;/label&gt;&lt;input id="blue" type="radio" name="color" value=".blue" /&gt;
  &lt;label for="green"&gt;green&lt;/label&gt;&lt;input id="green" type="radio" name="color" value=".green" /&gt;
  &lt;label for="non"&gt;none&lt;/label&gt;&lt;input id="non" type="radio" name="color" value=".none" /&gt;
  &lt;hr/&gt;
  &lt;div class="item one yellow"&gt;yellow&lt;/div&gt;
  &lt;div class="item two red"&gt;red&lt;/div&gt;
  &lt;div class="item one blue"&gt;blue&lt;/div&gt;
  &lt;div class="item two green"&gt;green&lt;/div&gt;
  &lt;div class="item one red green"&gt;red green&lt;/div&gt;
  &lt;div class="item two red blue"&gt;red blue&lt;/div&gt;
  &lt;div class="item one blue green"&gt;blue green&lt;/div&gt;
  &lt;div class="item two red blue green"&gt;red blue green&lt;/div&gt;
  </code></pre>
  
  <p>So in this example, I'd like if the "one" and the "red" are selected, the element that should show would be "red green", or if "two" and "blue" - "red blue" and "red blue green". Any thoughts or ideas?</p>