jQuery链式调用的原理分析
jQuery在封装的时候把操作DOM的api函数封装并且放到了jQuery函数内部的原型对象是哪个
并且封装的api函数都有一个返回值this,这个this指向的是jQuery的实例。
class Factory{
constructor(){
}
a(){
console.log("a")
return this
}
b(){
console.log("b")
return this
}
c(){
console.log("c")
return this
}
}
var FactoryObj=new Factory()
FactoryObj.a().b().c()
function Zy(){
this.a=function a(){
console.log(1)
return this
}
this.b=function b(){
console.log(2)
return this
}
this.c=function c(){
console.log(3)
return this
}
}
var zy=new Zy()
zy.a().b().c()
jQuery链式调用的原理分析
jQuery在封装的时候把操作DOM的api函数封装并且放到了jQuery函数内部的原型对象是哪个
并且封装的api函数都有一个返回值this,这个this指向的是jQuery的实例。