title: Filter element based on .data() key/value
body: <p>Say I have 4 div elements with class <code>.navlink</code>, which, when clicked, use <code>.data()</code> to set a key called <code>'selected'</code>, to a value of <code>true</code>:</p>
  
  <pre><code>$('.navlink')click(function() { $(this).data('selected', true); })
  </code></pre>
  
  <p>Every time a new <code>.navlink</code> is clicked, I would like to store the previously selected <code>navlink</code> for later manipulation. Is there a quick and easy way to select an element based on what was stored using <code>.data()</code>?</p>
  
  <p>There don't seem to be any jQuery <strong>:filters</strong> that fit the bill, and I tried the following (within the same click event), but for some reason it doesn't work:</p>
  
  <pre><code>var $previous = $('.navlink').filter( 
      function() { $(this).data("selected") == true }
  );
  </code></pre>
  
  <p>I know that there are other ways to accomplish this, but right now I'm mostly just curious if it can be done via <code>.data()</code>.</p>