title: why $("input[id='username']") works and $("#username") won't?
body: <p><strong>Update</strong>
  I guess I was to quick to assume voodoo jquery mystery. I noticed I do use the "username" Id twice and that is the problem. the second username id was added to the page through html code that was injected to the page from php, so I couldn't see it in the source at first..</p>
  
  <p>I'm writing this client side validation jquery code:</p>
  
  <pre><code>username = $("#username").val();
  
  if (username.length &lt; 5 || username.length &gt; 15 || !username_regex.test(username)) {
                  error += "invalid username\n";
                  $(this).find("label[for='username']").css("color", "red");
                  $("#username").css("background-color", "#ffc9c9").css("border-color", "red"); //this doesn't work
                  // $("input[id='username']").css("background-color", "#ffc9c9").css("border-color", "red");  //this works
              }
  </code></pre>
  
  <p>and the html:</p>
  
  <pre><code>  &lt;p&gt;&lt;label for="username"&gt;Username&lt;/label&gt;&lt;input id="username" type="text" name="username"/&gt;&lt;/p&gt;
  </code></pre>
  
  <p>I have several more jquery/html blocks, exactly the same as these above, for password, email, first name etc..</p>
  
  <p>this validation code is part of onsubmit handler and all of the other blocks are working fine: when a field is not met with the validation criteria, the color of it's label turns red and the background color of it's input field turns to #ffc9c9.</p>
  
  <p>the problem is in the username - it's label does turns red, but it's input field does not turns #ffc9c9. I don't see any reason for it not to work, I use the same line:</p>
  
  <pre><code> $("#*input_field_id*").css("background-color", "#ffc9c9").css("border-color", "red");
  </code></pre>
  
  <p>for every one of the other blocks and it works fine for them.</p>
  
  <p>also see that the commented line:</p>
  
  <pre><code>$("input[id='username']").css("background-color", "#ffc9c9").css("border-color", "red");
  </code></pre>
  
  <p>does work and solves my need. but it doesn't solves the mystery and I'm trying to figure out why don't the line above work.
  also notice that I have debugged with firebug and got expected results, for example:</p>
  
  <pre><code>$("#username").attr("name"); // = username, as expected
  </code></pre>
  
  <p>It comes down to this: why <code>$("input[id='username']")</code> works when I try to change it's css but <code>$("#username")</code> won't  ?</p>