Placeholder在IE8的兼容问题

<script type="text/javascript">  
 if( !('placeholder' in document.createElement('input')) ){  
 
   $('input[placeholder],textarea[placeholder]').each(function(){   
     var that=$(this),   
     text= that.attr('placeholder');   
     if(that.val()===""){   
       that.val(text).addClass('placeholder');   
     }   
     that.focus(function(){   
       if(that.val()===text){   
         that.val("").removeClass('placeholder');   
       }   
     })   
     .blur(function(){   
       if(that.val()===""){   
         that.val(text).addClass('placeholder');   
       }   
     })   
     .closest('form').submit(function(){   
       if(that.val() === text){   
         that.val('');   
       }   
     });   
   });   
 }  
</script>

TSAAS开源社区

posted @ 2016-07-25 11:36  quantumcs  阅读(166)  评论(0编辑  收藏  举报