title: Complex jquery selector loop function
body: <p>I need to find in a list and list item with a particular ID, the <code>&lt;a&gt;</code> with an href equal to a variable <code>&lt;li&gt;</code>  (and then add a particular class to it).</p>
  
  <pre><code>&lt;ul id="elementSelectionList"&gt;
     &lt;li&gt;&lt;a href="#bzm_tagline" class="text"&gt;Tagline&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;input id="form_tagline" name="tagline" value=""&gt;
  </code></pre>
  
  <p>.</p>
  
  <pre><code> $('#fields input').each(function (){
          var elementListing = this.id.replace('form', 'bzm');
  
          if( !$(this).val() ) {
              $('#elementSelectionList li a[href*="#' + elementListing + '"]')
                  .hasClass('text')
                  .removeClass('filled')
                  .addClass('empty');
          } 
   });
  </code></pre>
  
  <p>I'm getting the error: object false has no method 'removeClass'.
  Want to know how I can acheive what I'm trying to do...</p>