JQuery 获取Dom元素的实例讲解
2019/6/27 20:50:02
本文主要是介绍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元素的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持找一找教程网。
这篇关于JQuery 获取Dom元素的实例讲解的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-24Vue CLI多环境配置学习:从入门到实践
- 2024-11-24Vue CLI多环境配置学习:新手入门教程
- 2024-11-24Vue CLI学习:初学者指南
- 2024-11-24Vue CLI学习:从入门到上手的简单教程
- 2024-11-24Vue3+Vite学习:从零开始的前端开发之旅
- 2024-11-24Vue3阿里系UI组件学习入门教程
- 2024-11-24Vue3的阿里系UI组件学习入门指南
- 2024-11-24Vue3公共组件学习:新手入门教程
- 2024-11-24Vue3公共组件学习入门指南
- 2024-11-24vue3核心功能响应式变量学习