手掌心
这是Android浏览器中的一个bug,之前遇到过,没有好的办法,最后用div标签hack了一下,基本实现了需求,供参考。javascript(function($){vartest=document.createElement('input');varsupport='placeholder'intest&&!/android/gi.test(window.navigator.userAgent);$.fn.placeholder=function(){returnthis.each(function(){if(support)return;var$this=$(this);varholderText=$this.attr('placeholder');varholder=$(''+holderText+'');holder.css({position:'absolute',display:'none',zIndex:999,cursor:'text',wordWrap:'break-word',color:'#bbb'});$this.after(holder).removeAttr('placeholder').parent().css('position','relative');$this.bind('focus',function(){holder.hide();}).bind('blur',function(){if($this.val().length)return;varoffset=$this.offset();vartop=(parseInt($this.css('paddingTop'),10)||0)+(parseInt($this.css('borderTop'),10)||0);varleft=(parseInt($this.css('paddingLeft'),10)||0)+(parseInt($this.css('borderLeft'),10)||0);holder.css({top:top,left:left,width:$this.width()}).show();}).trigger('blur');holder.bind('click',function(){$this.focus();});});};})(jQuery);//调用方法$('textarea').placeholder();