用JavaScript解决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>

  非常棒

上一篇:mysql中判断表中是否存在某条记录


下一篇:Warning: File upload error - unable to create a temporary file in Unknown on line 0