title: IE9 HTML5 placeholder - how are people achieving this?
body: <p>I'm trying to use the <code>placeholder="xxx"</code> attribute in my web application, and I don't want to have a special visual for IE9. Can people throw out some good suggestions for achieving this functionality in IE9?</p>
  
  <p>I've found a couple links on here but none of the suggested scripts were sufficient... and the answers were from mid-2011, so I figured maybe there is a better solution out there. Perhaps with a widely-adopted jQuery plugin? I do not want to use anything that requires intrusive code such as requiring a certain css class or something.</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong> - I also need this to work for password input fields.</p>
  
  <pre><code>// the below snippet should work, but isn't.
  $(document).ready(function() {
     initPlaceholders()();
  }
  
  function initPlaceholders() {
          $.support.placeholder = false;
  var test = document.createElement('input');
  if ('placeholder' in test) {
      $.support.placeholder = true;
      return function() { }
  } else {
      return function() {
          $(function() {
              var active = document.activeElement;
              $('form').delegate(':text, :password', 'focus', function() {
                  var _placeholder = $(this).attr('placeholder'),
                      _val = $(this).val();
                  if (_placeholder != '' &amp;&amp; _val == _placeholder) {
                      $(this).val('').removeClass('hasPlaceholder');
                  }
              }).delegate(':text, :password', 'blur', function() {
                  var _placeholder = $(this).attr('placeholder'),
                      _val = $(this).val();
                  if (_placeholder != '' &amp;&amp; (_val == '' || _val == _placeholder)) {
                      $(this).val(_placeholder).addClass('hasPlaceholder');
                  }
              }).submit(function() {
                  $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
              });
              $(':text, :password').blur();
              $(active).focus();
          });
      }
  }
  }
  </code></pre>