Why return this.each(function()) in jQuery plugins?

后端 未结 5 2094
感情败类
感情败类 2020-12-01 02:00

Some of the tutorials and examples I have seen for developing jQuery plugins tend to return

this.each(function () {
    //Plugin code here
});
5条回答
  •  无人及你
    2020-12-01 02:20

    When you write a plugin you are extending the jQuery object, and because the jQuery object is a sequence you return this.each(function () { }); so that your plugin is executed for each item of the sequence.

提交回复
热议问题