placeholder js简单实现

时间:2022-04-22 03:56:51
  window.onload = function() {
var input = document.getElementById("input");
input.onblur = function() {
this.value = (this.value == '' ? this.defaultValue : this.value);
};
input.onfocus = function() {
this.value = (this.value == this.defaultValue ? '' : this.value);
};
};