zoukankan      html  css  js  c++  java
  • 提前定义好的一些必要函数

    String.prototype.trim = function() {

       return $.trim(this);

    };

    (function($) {

    $.substitute = function(template, data) {
    return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
    var keys = key.split("."), value = data[keys.shift()];
    $.each(keys, function () { value = value[this]; });
    return (value === null || value === undefined) ? "" : value;
    });
    };
    $.log = function(text) {
    if (typeof(console) != 'undefined' && console.log) {
    console.log(text);
    }
    };
    $.pngfix = function(node) {
    if (typeof(DD_belatedPNG) !== 'undefined') {
    DD_belatedPNG.fix(node);
    }
    };
    $.isIE6 = function() {
    return ($.browser.msie && $.browser.version == '6.0');
    };
    $.isIE7 = function() {
    return ($.browser.msie && $.browser.version == '7.0');
    };
    $.atopfix = function(node) {
    if(typeof document.body.style.maxHeight === "undefined") {
    $(node).click( function(e) {
    //e.preventDefault();
    if(window.top) {
    window.top.location = $(this).attr('href');
    }
    });
    }

    };

    })(jQuery);

    // string helpers
    (function($) {
    String.prototype.trim = function() {
    return $.trim(this);
    };
    String.prototype.endWith=function(s){
    if (s == null || s == '' || this.length === 0 || s.length > this.length) {
    return false;
    }
    return (this.substring(this.length - s.length) === s);
    };
    String.prototype.startWith=function(s) {
    if (s == null || s == '' || this.length === 0 || s.length > this.length) {
    return false;
    }
    return (this.substr(0,s.length) === s);
    };
    })(jQuery);

  • 相关阅读:
    iOS APM性能统计
    iOS promise
    静态代码检测工具Infer的部署
    ES读写数据的工作原理
    关于 Elasticsearch 内存占用及分配
    Elasticsearch中数据是如何存储的
    ES中的选举机制
    .net core 3.1 webapi解决跨域问题 GET DELETE POST PUT等
    .net framework WEBAPI跨域问题
    Angular前端项目发布到IIS
  • 原文地址:https://www.cnblogs.com/mabelstyle/p/2873284.html
Copyright © 2011-2022 走看看