Adding and removing classes in jQuery
<p>I have a jQuery snippet written where if any of my inputs in a specific table are entered it changes the class of the rest of the inputs on that table, but if the user fills in an input field, and then deletes their input it still changes the class, though it shouldnt.  here is my attempt at doing this.</p>

<pre><code> $('#lostTable :input').change(function(){                                          

        var $lostTableInput = $('#lostTable :input:not(input[type=hidden])');
        var hasData = false;

        $lostTableInput.each(function(){
            if($(this).val().length &gt; 0){
                hasDataLf = true;
                return false;
            }
        });

    $lostTableInput.toggleClass('R', hasDataLf); 

// this above part works for changing the class, and below is my attempt at changing
// it back if the user deletes the data that was entered in.

    $lostTableInput.each(function(){
      if($(this).val().length == 0) {
        $lostTableInput.removeClass('R'); 
    }
   }
  )
 }
);
</code></pre>
