<p> <input type="text" class="input" name="name" value="姓名NAME:""/></p>
$(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; } }); });});新聞熱點
疑難解答