What real purpose does $.noop() serve in jQuery 1.4?

前端 未结 9 751
故里飘歌
故里飘歌 2020-12-30 19:01

Pouring over the release notes regarding jQuery 1.4, I came acrosss $.noop() which is:

Description: An empty function. (added in 1.4)

9条回答
  •  不思量自难忘°
    2020-12-30 19:26

    I use a couple of plugins which require callbacks, but for some parts I don't actually want to use a certain callback. So, I put in function() {}.

    noop is defined in the jQuery source as

    noop: function() {}
    

    so it will fit anywhere you'd use a blank function, such as the above example.

提交回复
热议问题