zoukankan      html  css  js  c++  java
  • javascript常用的方法(二)

    //判断页面加载完毕
    document.onreadystatechange = function () {
        if (document.readyState == "complete") {
            //code...
        }
    }
    //判断是否全为手机
    String.prototype.isMobile = function () {
        var pattern = /^0{0,1}(13[0-9]|14[6|7]|15[0-3]|15[5-9]|18[0-3]|18[5-9])[0-9]{8}$/;
        return pattern.test(this);
    }
    //判断是否全为中文
    String.prototype.isChinese = function () {
        var pattern = /^[u4e00-u9fa5]+$/;
        return pattern.test(this);
    }
    //判断是否全为英文
    String.prototype.isEnglish = function () {
        var pattern = /^[a-zA-Z]+$/;
        return pattern.test(this);
    }
    //判断是否为空
    String.prototype.isEmpty = function () {
        var _this = this;
        if (_this == "")
            return true;
    }
    //清除空格
    String.prototype.Trim = function () {
        return this.replace(/(^s*)|(s*$)/g, "");
    }
    
    /* 检测级数中是否包含此项
    var ar = ["a", "b"];
    if (ar.contains("a"))
    alert("true");  //结果:true
    */
    Array.prototype.contains = function (element) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == element) {
                return true;
            }
        }
        return false;
    }
    
  • 相关阅读:
    关于此博客的制作
    Java线程运行轨迹-代码追踪与定位
    MySQL安装和使用
    jenkins安装和使用教程
    持续集成(git+TortoiseGit+Gitblit)
    RF框架基础知识(二)
    RF工具ride使用
    Postman的使用
    用Python写RF测试
    RF框架基础知识(一)
  • 原文地址:https://www.cnblogs.com/sntetwt/p/3791377.html
Copyright © 2011-2022 走看看