JQuery 获取Dom元素的实例讲解

编程学习 2021-07-04 18:32www.dzhlxh.cn编程入门
狼蚁网站SEO优化长沙网络推广就为大家带来一篇JQuery 获取Dom元素的实例讲解。长沙网络推广觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随长沙网络推广过来看看吧

废话不多说,直接上代码

(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元素的实例讲解就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板