JQuery 获取Dom元素的实例讲解
废话不多说,直接上代码
(function(window){
vararr=[];
varVP=function(selector,context){
returnnewVP.fn.init(selector,context);
}
VP.fn=VP.prototype={
constructor: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;
}
}
returnthis;
},
splice:arr.splice,
};
VP.extend=VP.fn.extend=function(){
varoptions,name,src,copy,copyIsArray,clone,
target=arguments[0]||{},
i=1,
length=arguments.length,
deep=false;
if(typeoftarget==="boolean"){
deep=target;
target=arguments[i]||{};
i++;
}
if(typeoftarget!=="object"&&!VP.isFunction(target)){
target={};
}
if(i===length){
target=this;
i--;
}
for(;i
以上这篇JQuery获取Dom元素的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。