实现表单的输入框当光标为当前时,去掉默认值

作用:实现表单的输入框当光标为当前时,去掉默认值,当光标离开原默认值没有发生改变时,再次显示默认值,按钮除外;

实现代码如下(jquery版):

$(":input").not(":input[type=submit],:input[type=button]").focus(function(){
          if($(this).val() ==this.defaultValue){  
              $(this).val("");           
          } 
    }).blur(function(){
         if ($(this).val() == '') {
            $(this).val(this.defaultValue);
         }
    });
原文地址:https://www.cnblogs.com/waitingbar/p/3156746.html