zoukankan      html  css  js  c++  java
  • work_03_常见jq问题处理

    1.获取不同浏览器按下的键码

    $(document).ready(function(){
       $("#keydown").keydown(function(event){
            var keycode = (event.keyCod ? event.keyCode : event.which);
            console.log("keycode:" + keycode);
            }
        }) 
    })    

    2.输入卡号卡号规则***** **** **** ****** 中间有空格

    $('#cardno').on('input', function () {
            //去掉所有空格
            this.value = this.value.replace(/s/g, "");
    
            if (/^[0-9]*[1-9][0-9]*$/.test(this.value)) {
                var len = this.value.length;
                if (len >= 6 && len <=9) {
                    this.value = this.value.substring(0, 5) + " " + this.value.substring(5)
                } else if (len >= 10 && len <=13) {
                    this.value = this.value.substring(0, 5) + " " + this.value.substring(5, 9) + " " + this.value.substring(9)
                } else if (len >= 14 && len <=20) {
                    this.value = this.value.substring(0, 5) + " " + this.value.substring(5, 9) + " " + this.value.substring(9, 13) + " " + this.value.substring(13)
                }
            }
        })
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    关于if和else和switch case的用法和程序编码操作过程
    关于java的特点
    关于JAVA的数据类型
    关于java的学习
    力扣482. 密钥字符串 S python--每天一题
  • 原文地址:https://www.cnblogs.com/asndxj/p/12524052.html
Copyright © 2011-2022 走看看