title: input field placeholder in jQuery
body: <p>I'm trying to create a Login page, not worrying about actually logging in yet, but I'm trying to achieve the effect where there is some faded text inside the input field and when you click on it, the text disappears or if you click away the text reappears.</p>
  
  <p>I have this working for my "Username" input field, but the "Password" field is giving me problems because I can't just do <code>$("#password").attr("type","password")</code>. Here's my code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
  
      &lt;!-- Links --&gt;
      &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
  
      &lt;!-- Scripts --&gt;
      &lt;script type="text/javascript" src="jQuery.js"&gt;&lt;/script&gt;
      &lt;script&gt;
  
          // document script
          $(document).ready(function(){
  
              // login box event handler
              $('#login').click(function(){
  
                  $('.loginBox').animate({ 
                      height: '150px'
                  }, 
                      '1000'
                  );
                  $('#username').show();
  
                  // add pw placeholder field
                  $('#password').after('&lt;input type="text" id="placeHolder" value="Password" class="placeHolder" /&gt;');
                  $('#password').hide();
              });
  
              // username field focus and blur event handlers
              $('#username').focus(function() {
                  if($(this).hasClass('placeHolder')){
                      $(this).val('');
                      $(this).removeClass('placeHolder');
                  }
              });
              $('#username').blur(function() {
                  if($(this).val() == '') {
                      $(this).val('Username');
                      $(this).addClass('placeHolder');
                  }
              });         
  
              // password field focus and blur event handlers
              $('#placeHolder').focus(function() {
                  $('#placeHolder').hide();
                  $('#password').show();
                  $('#password').focus();
              });
              $('#password').blur(function() {
                  if($('#password').val() == '') {
                      $('#placeHolder').show();
                      $('#password').hide();
                  }   
              });
  
          });
  
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div id="loginBox" class="loginBox"&gt;
          &lt;a id="login"&gt;Proceed to Login&lt;/a&gt;&lt;br /&gt;
          &lt;div id="loginForm"&gt;
              &lt;form&gt;
                  &lt;input type="text" id="username" class="placeHolder" value="Username" /&gt;
                  &lt;input type="password" id="password" class="placeHolder" value="" /&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Right now, I can click on the password input box and type in it, but the text is not disappearing and the "type" doesn't get set to "password"... the new input field I create isn't being hidden, it just stays visible, and I'm not sure where the problem is. Any ideas?</p>