zoukankan      html  css  js  c++  java
  • 实现表单的输入框当光标为当前时,去掉默认值

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

    实现代码如下(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);
             }
        });
  • 相关阅读:
    泛型
    多播委托
    匿名方法
    委托
    正则表达式
    压缩和解压,文件读取练习
    Vue样式绑定
    Vue跑马灯
    Vue中的v-for遍历循环
    Vue框架
  • 原文地址:https://www.cnblogs.com/waitingbar/p/3156746.html
Copyright © 2011-2022 走看看