//IE也支持placeholder
placeholderUp();
function placeholderUp(){
var i = document.createElement('input'),
laceholdersupport = 'placeholder' in i;
//只处理IE的情况
if(!placeholdersupport){
var inputObj = $(':text');
inputObj.each(function(){
var that = $(this),
thatPlaceholder = that.attr("placeholder");
that.val(thatPlaceholder);
that.on('focus',function(){
if(that.val() == thatPlaceholder){
that.val('');
}
})
that.on('blur',function(){
if(!that.val()){
that.val(thatPlaceholder);
}
})
});
}
}
注:依赖Jquery