• jQuery 获取DOM元素


    (function (window){

    var arr=[];

    var VP=function(selector,context){

    return new VP.fn.init(selector,context);

    }

    VP.fn=VP.prototype={

    contstructor:VP,

    init:function(selector,context){

    var _document=window.document,elem,mark=selector.charAt(0);

    if(mark=='#'){

    elem =_document.getElementById(selector.substring(1));

    if(elem){

    this[0]=elem;

    this.length=1;

    }

    }

    return this;

    },

    splice:arr.splice,

    };

    VP.extend=VP.fn.extend=function(){

    var options,name,src,copy,copyIsArray,clone,target=arguments[0]||{},

    i=1,

    length=arguments.length,

    deep=false;

    if(typeof target=="boolean"){

    deep=target;

    target=arguments[i]||{};

    i++;

    }

    if(typeof target !=="object"&&!VP.isFunction(target)){

    target={};

    }

    if(i==length){

    target=this;

    i--;

    }

    for(;i<length;i++){

    for(name in options){

    src=target[name];

    copy=options[name];

    if(target==copy){

    continue;

    }

    if(deep&&copy&&(VP.isPlainObject(copy)||

    (copyIsArray=VP.isArray(copy)))){

    if(copyIsArray){

    copyIsArray=false;

    clone=src && VP.isArray(src)?src:[];

    }

    else{

    clone=src&&VP.isPlainObject(src)?src:{};

    }

    target[name]=VP.extend(deep,clone,copy);

    }

    else if(copy !==undefined){

    target[name]=copy;

    }

    }

    }

    }

    return target;

    };

    VP.fn.extend({

    get:function(){

    return this[0];

    },

    });

    VP.fn.init.prototye=VP.fn;

    window.VP=VP;

    })(window);

  • 相关阅读:
    hdu 1142 用优先队列实现Dijkstra
    POJ 2063 Investment 完全背包
    POJ 3260 多重背包+完全背包
    bignum 大数模板
    POJ 3468(树状数组的威力)
    POJ 3468 线段树裸题
    hdu 1058 Humble Numbers
    CodeForces 185A 快速幂
    POJ 1990 MooFest 树状数组
    设计模式(20)策略模式
  • 原文地址:https://www.cnblogs.com/zzp0320/p/7145865.html
Copyright © 2020-2023  润新知