$(document).ready(function() {//each遍历文本框$(".input").each(function() {//保存当前文本框的值var vdefault = this.value;$(this).focus(function() {//获得焦点时,如果值为默认值,则设置为空if (this.value == vdefault) {this.value = "";}});$(this).blur(function() {//失去焦点时,如果值为空,则设置为默认值if (this.value == "") {this.value = vdefault;}});});});希望本文所述对大家的jQuery程序设计有所帮助。