让ie8支持 placeholder 属性

   一、  ie8支持 placeholder 属性

 /*
  * ie8支持 placeholder 属性
  */
 $(function(){
 	 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('');   
		        }   
		      });   
		    });   
	  } 
 })
原文地址:https://www.cnblogs.com/zjf-1992/p/6380364.html