JavaScript 库 - jQuery、Prototype、MooTools 所有这些框架都提供针对常见 JavaScript 任务的函数,包括动画、DOM 操作以及 Ajax 处理。...jQuery 是目前最受欢迎的 JavaScript 框架。 它使用 CSS 选择器来访问和操作网页上的 HTML 元素(DOM 对象)。...jQuery 同时提供 companion UI(用户界面)和插件。...下面进行介绍: 向页面添加 jQuery 库 jquery.js"> jQuery...基础语法是:$(selector).action() 美元符号定义 jQuery 选择符(selector)“查询”和“查找” HTML 元素 jQuery 的 action() 执行对元素的操作
Label和Selector的应用Label和Selector是Kubernetes中的重要概念,它们在以下场景中应用广泛:应用程序部署:在Kubernetes中,标签和选择器是部署应用程序的重要机制。...在Service对象中,使用标签和选择器来标识和选择与服务关联的Pod。监控和日志:通过为Pod和其他对象添加标签,您可以使用标签和选择器来标识和选择对象,然后使用这些标签来监控和记录它们的运行状态。...示例下面是一些使用标签和选择器的示例:标记Pod:apiVersion: v1kind: Podmetadata: name: nginx labels: app: web tier:...使用标签选择Pod:kubectl get pods -l app=web,tier=frontend使用上面的命令,我们可以选择具有“app=web”和“tier=frontend”标签的Pod。...使用标签选择Service:apiVersion: v1kind: Servicemetadata: name: nginx-servicespec: selector: app: web
在Kubernetes中,Label和Selector是两个非常重要的概念。它们被用于标识和选择Kubernetes中的对象,如Pod、Service、Deployment等。...它们可以用于将对象分类、过滤和组合,并可用于选择要处理的对象。标签的常见用途包括:对象的分类:例如,将所有具有相同用途或属性的Pod分组在一起。...containers: - name: nginx image: nginx:latest ports: - containerPort: 80在这个示例中,Pod被标记为“app=nginx”和“...Selector是用于选择带有特定标签的Kubernetes对象的一种机制。使用选择器,您可以选择与指定的标签匹配的对象。选择器是在Kubernetes对象的元数据中定义的。...Deployment对象的示例:apiVersion: apps/v1kind: Deploymentmetadata: name: nginx-deploymentspec: replicas: 3 selector
jQuery.fn.init() } jQuery.prototype = { constructor: jQuery } jQuery.fn.init.prototype...= jQuery.prototype window.jQuery = window.$ = jQuery })(window); /* 其中fn指代的是原型,因此以上结构可以转换成以下结构 *...(); }; jQuery.prototype = { constructor: jQuery, }; jQuery.prototype.init.prototype...= jQuery.prototype; window.jQuery = window.$ = jQuery; })(window); jQuery的本质是一个闭包 为了避免多个框架的冲突.../ 为类和对象添加方法 / kjQuery.extend = kjQuery.prototype.extend = function (obj) { for (var key in obj)
另一方面,现阶段 React、Vue 和 Angularjs 等主流前端框架并不依赖 jQuery,都可以独立使用。...(selector, context); }; _$.prototype = { //初始化$ Init: function (selector, context) {...为的是和 .extend 作区分 $.fn.extend ; (function (win) { ... _$.prototype.Init.prototype = _$.prototype;..._$.fn = _$.prototype; //把对象挂载到jQuery的prototype属性 var isObj = (o) => Object.prototype.toString(...(selector, context); }; _$.prototype = { //初始化$ Init: function (selector, context) {
()); // undefined jQuery中的链式调用 jQuery是一个高端而不失奢华的框架,其中有许多非常精彩的方法和逻辑,虽然现在非常流行于类似于Vue、React的MVVM模式的框架,但是...function _jQuery(selector){ return _jQuery.fn.init(selector); } _jQuery.fn = _jQuery.prototype =...function _jQuery(selector){ return _jQuery.fn.init(selector); } _jQuery.fn = _jQuery.prototype =...function _jQuery(selector){ return new _jQuery.fn.init(selector); } _jQuery.fn = _jQuery.prototype...function _jQuery(selector){ return new _jQuery.fn.init(selector); } _jQuery.fn = _jQuery.prototype
实践是最好的证明,一定要相信这句话 在我自己动手敲代码之前,对于原型对象、父类子类等的了解只是停留在概念上,对于prototype和proto也是自认为明白清楚,但在真正动手敲一遍代码实现之后,才发现原来真的是需要自己边敲边领悟的啊...__proto__.prototype)//undefined console.log(A.prototype....__proto__)//[Object:null prototype]{} console.log(A.prototype.prototype)//undefined console.log(B)//...__proto__)//class A B的父类是A console.log(B.prototype)//A {} 说明B的原型对象是A的原型对象的实例 console.log(B.prototype.prototype...__proto__.prototype===A.prototype)//true //实例 let a=new A() let b=new B() console.log(b.
(){ return new jQuery.prototype.init(); } jQuery.prototype={ constructor:jQuery...} jQuery.prototype.init.prototype = jQuery.prototype; window.jQuery=window....) { var kjQuery = function(selector) { return new kjQuery.prototype.init(selector); } kjQuery.prototype...= { constructor: kjQuery, init: function(selector) { //去除开头和结尾的空格 selector = kjQuery.trim(...= selector; //优化第二和第三步 [].push.apply(this, temp.children); } else { // 选择器:会将所有找的元素存储到
right="0dp" android:top="0dp"/> c.使用 android:background="@drawable/shape_test" 2.selector...> selector xmlns:android="http://schemas.android.com/apk/res/android"> selector> b.使用 android:background="@drawable.../btn_selector_test"
JS 原型(隐式原型和显示原型)JS原型 每个class都有显式原型 prototype 每个class实例化后都有隐式原型 proto 实例的隐式原型指向对应class的显式原型instanceof...)每个实例对象都有 proto / [[prototype]](隐式原型)实例对象的proto (隐式原型) 指向构造函数的 prototype(显式原型)执行规则:获取实例对象的属性或方法时先在自身属性和方法寻找若找不到则自动通过原型链一层一层向上查找此原型链图解可对照上面...使用instanceof/Array.isArray方法手写jqueryclass jQuery { constructor(selector) { const result = document.querySelectorAll...(elem => { elem.addEventListener(type, fn, false) }) } // 扩展很多 DOM API}// 插件jQuery.prototype.dialog...= function (info) { alert(info)}// “造轮子”class myJQuery extends jQuery { constructor(selector)
这个方法直接调用了jQuery.fn.init,这个方法也可以直接在文件里面搜到,我们发现他支持几种selector: 字符串,DOM元素和方法,如果展开他们,你会发现他们都是根据selector去把匹配的结果挂载到...那我们平时使用的$('selector').first()和$.ajax又是怎么实现的呢,似乎整个调用流程都没看到这些方法呢。...原来在jQuery.fn.init函数定义下面我们还发现了一行代码: ? 这行代码将jQuery.fn也就是jQuery.prototype又赋值给了jQuery.fn.init.prototype。...网上经常看到有人问,jQuery.extend和jQuery.fn.extend有啥区别。...jQuery是通过$.fn.extend和$.extend来做的,而Zepto是通过自执行函数,将Zepto作为参数传进去,然后在自执行函数里面直接对$和$.fn添加属性来实现的。
jQuery.fn赋值原型链 jQuery.fn = jQuery.prototype = { jquery: version } 3 init = jQuery.fn.init = function...( selector, context, root ){ //init函数的具体操作 } init.prototype = jQuery.fn;//将init原型链赋值jQuery.fn,jQuery.fn...第二行定义jQuery.fn来接收jQuery的原型,并写入了一些变量和函数。 第三行定义init这个变量等于jQuery.fn.init在赋值一个init操作的函数。...jQuery是把得到原型链和存入需要操作的dom都在一个函数里完成,我则是分开完成的。...SmhJquery.fn.init(selector); }; SmhJquery.fn = SmhJquery.prototype = {
= function( selector, context ) { // 返回new之后的对象 return new jQuery.fn.init( selector,...selector ) { return this; } // ... }; init.prototype = jQuery.fn; jQuery.fn === jQuery.prototype...({jQuery}); // 在谷歌浏览器控制台,可以看到jQuery函数下挂载了很多静态属性和方法,在jQuery.fn 上也挂着很多属性和方法。...可以给jQuery上添加静态方法和属性,也可以像 jQuery.fn(也就是 jQuery.prototype)上添加属性和方法,这个功能归功于 this, jQuery.extend调用时 this指向是...jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context
原型 原型是function对象下的属性,它定义了构造函数的共同祖先,也就是一个父子级的关系,子对象会继承父对象的方法和属性 prototype是函数下的属性,对象想要查看原型使用隐式属性__Proto...__ constructor指向构造函数 自己身上有属性,原型上也有属性,取近的,用自己的 通过给原型添加属性,可以让所有的实例化对象共享属性和方法 Car.prototype = { height...是函数特有的,__proto__是对象有的,js中万物皆对象 prototype和——proto——区别与作用 prototype把共有属性预先定义好,给之后对象使用 prototype的存在实现了继承...,那么就会沿着它的**__proto__**属性所指向的那个对象(父对象)里找,也就是原型链 prototype的作用是就是让该函数所实例化的对象们都可以找到公用的属性和方法 __proto__对象原型的意义就在于为对象的查找机制提供一个方向...__和prototype,它指向构造函数本身 一般情况下,对象的方法都在构造函数的原型对象中设置。
是jQuery的真正构造函数 return new jQuery.fn.init(selector) } jQuery.fn = jQuery.prototype = { constructor...在代码中可以看到,jQuery自身对于原型的处理使用了一些巧妙的方式,比如jQuery.fn = jQuery.prototype,jQuery.fn.init.prototype = jQuery.fn...jQuery.fn = jQuery.prototype = { init: {} } 之后又将init的原型,指向了jQuery.prototype。...(selector) } 最后对外暴露入口时,将字符$与jQuery对等起来。...// Drag对象简化代码,完整源码可在上一篇文章中查看 ; (function () { // 构造 function Drag(selector) { } // 原型 Drag.prototype
而一旦你把这个函数当作构造函数(constructor)调用(即通过new关键字调用),那么JS就会帮你创建该构造函数的实例,实例继承构造函数prototype的所有属性和方法(实例通过设置自己的__proto...__指向承构造函数的prototype来实现这种继承)。...先有Object.prototype(原型链顶端),Function.prototype继承Object.prototype而产生,最后,Function和Object和其它构造函数继承Function.prototype...prototype 每个函数都有一个属性叫做prototype,这个prototype的属性值是一个对象(属性的集合),默认的只有一个叫做constructor的属性,指向这个函数本身。...prototype 作为一个对象是可以塞很多属性和方法的。 __proto__ 每个对象都有一个隐式原型。每个对象都有一个__proto__属性,指向创建该对象的函数的prototype。
6)静态方法和prototype(难) 例 3.6.1 和java中一样的。或者说function外或任何地方都可以访问Student.number。...String.prototype.abcd,这是给所有的实例加属性而不是静态属性。...Student.number*/ document.writeln("static method is " + Student.number); }; Student.prototype.infop
的实例,即jQuery对象 * selector待查找的字符串,源码里还有context参数,此处省略 * 我们所说的jQuery其实准确的说是jQuery工厂方法,调用jQuery...工厂方法返回的才是真正的jQuery对象 */ var jQuery = function(selector){ return new jQuery.fn.init...(selector); }, version = "3.2.1"; //jQuery原型对象赋值给jQuery.fn,定义在jQuery.prototype...对象就是它)可以使用jQuery.fn的方法 * 结合之前可以得出 jQuery.fn.init.prototype = jQuery.fn = jQuery.prototype * jQuery.fn...,jQuery.prototype扩展的方法属性 jQuery对象可以使用 */ jQuery.fn.init.prototype = jQuery.fn; //实现了