what does “return this.each()” do in jQuery?

后端 未结 5 1061
轮回少年
轮回少年 2021-02-08 21:25

I\'m looking at a jQuery plugin, which has a single function. After setting up the appropriate defaults though a constructor argument the function defines a couple of helper fu

5条回答
  •  半阙折子戏
    2021-02-08 22:00

    It returns the JQuery object which method is called on as stated in the docs. So you can call another method on the returned value.

    // without method chaining
    myobject.a()
    myobject.b()
    myobject.c()
    
    // with method chaining
    myobject.a().b().c();
    

    See method chaining and fluent interface

提交回复
热议问题