码迷,mamicode.com
首页 > Web开发 > 详细

JQuery获取Dom元素的方法

时间:2017-08-27 12:51:37      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:extend   获取   sub   def   init   tin   for   function   boolean   

(function (window) {
var arr = [];
var VP = function (selector, context) {
return new VP.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;
}
}
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++) {
if ((options = arguments[i]) != null) {
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.prototype = VP.fn;
window.VP = VP;
})(window);

  

JQuery获取Dom元素的方法

标签:extend   获取   sub   def   init   tin   for   function   boolean   

原文地址:http://www.cnblogs.com/dwj88/p/7439954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!