写法
::-moz-placeholder{color:red} //ff
::-webkit-input-placeholder{color:red} //chrome,safari
::-ms-input-placeholder{color:red} //ie10
ie 6~9 模拟placeholder
var funPlaceholder = function(element) {
var placeholder = ' ';
if (element && !("placeholder" in document.createElement("input")) && (placeholder = element.getAttribute("placeholder"))) {
element.onfocus = function() {
if (this.value === placeholder) {
this.value = "";
}
this.style.color = '';
};
element.onblur = function() {
if (this.value === "") {
this.value = placeholder;
this.style.color = 'graytext';
}
};
//样式初始化if (element.value === "") {
element.value = placeholder;
element.style.color = 'graytext';
}
}
};