jquery

$到底做了什么?

jquery把元素包装成为了jquery的实例,这个实例继承了jquery的原型方法,这样子我们才能使用jquery的方法

链式调用原理

是在每个方法后return this

const fn = {
    fn1: function() {
        console.log("do something");
        return this;
    },
    fn2: function() {
        console.log("do something");
        return this;
    },
    fn3: function() {
        console.log("do something");
        return this;
    }
}
fn.fn1().fn2().fn3();
posted @ 2021-03-08 22:40  PiPai  阅读(76)  评论(0编辑  收藏  举报