Conditional formatting with element selector
<p>I'm trying to highlight all links that do not have a <code>href</code> set, or if it is blank. I wrote the following: <a href="http://jsfiddle.net/nSMEf/" rel="nofollow">http://jsfiddle.net/nSMEf/</a></p>

<pre><code>$(document).ready(function() {
  if ($('.green').attr("href") == "" || typeof $('.green').attr("href") === 'undefined'){
      $('.green').attr('class', 'yellow');
  }

  if ($('.blue').attr("href") == "" || typeof $('.blue').attr("href") === 'undefined'){
       $('.blue').attr('class', 'yellow');
  }
});
</code></pre>

<p>I noticed that the if statement seemed to apply only on which link came first, and all the following links would be styled the same. The second "blue" group is the same as the first but with the order switched.</p>

<p>My approach clearly isn't right. Is it possible to have the yellow class applied conditionally (based if the href is blank or not there) on each element?</p>
