title: IE8 'attr(...)' is null or not an object
body: <p>I'm trying to get a jquery IE placeholder fix to work.  It works fine in IE9 but in IE8 I keep getting an alert... </p>
  
  <blockquote>
    <p>'attr(...)' is null or not an object </p>
  </blockquote>
  
  <p>This is the code I am using.  Am I doing something wrong?</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;!--[if lte IE 9 ]&gt;
      &lt;script&gt;
          // IE Placeholder Fix
          $(function() {
              if ($('input[placeholder]').attr('placeholder').val() != '') {
                  var ph = $('input[placeholder]').attr('placeholder');
                  $('input[placeholder]').blur();
                  if ($('input[placeholder]').attr('value').val() == 0) {
                      $('input[placeholder]').attr('value', ph);
                      $('input[placeholder]').css('color','#999999');
                  };
                  $('input[placeholder]').click(
                      function() {
                          $(this).css('color','#000000');
                          if ($(this).attr('value') == ph) {
                              $(this).attr('value','');
                      }
                  });
              }
          });
      &lt;/script&gt;
  &lt;![endif]--&gt; 
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Using the comments below I came up with...</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;!--[if lte IE 9 ]&gt;
      &lt;script&gt;
          // IE Placeholder Fix
          $(function() {
              if ($('input[placeholder]').length != 0) {
                  var ph = $('input[placeholder]').attr('placeholder');
                  $('input[placeholder]').blur();
                  if ($('input[placeholder]').attr('value') == '') {
                      $('input[placeholder]').attr('value', ph);
                      $('input[placeholder]').css('color','#999999');
                  };
                  $('input[placeholder]').click(
                      function() {
                          $(this).css('color','#000000');
                          if ($(this).attr('value') == ph) {
                              $(this).attr('value','');
                      }
                  });
              }
          });
      &lt;/script&gt;
  &lt;![endif]--&gt; 
  </code></pre>