加载中...

callbacks.remove()1.7+


概述    callbacks.remove( callbacks )

返回值:Callbacks

描述:从回调列表中的删除一个回调或回调集合。

  • V : 1.7callbacks.remove( callbacks )

    • callbacks
      类型: Function, Array
      从回调列表中删除的一个函数,或者函数数组。

此方法返回绑定它的那个回调对象 (this).

示例

实例

用callbacks.remove() 删除回调或回调回调列表的集合。

jQuery 代码:
  1. // a sample logging function to be added to a callbacks list
  2. var foo = function( value ){
  3. console.log( 'foo:' + value );
  4. }
  5. var callbacks = $.Callbacks();
  6. // add the function 'foo' to the list
  7. callbacks.add( foo );
  8. // fire the items on the list
  9. callbacks.fire( 'hello' ); // outputs: 'foo: hello'
  10. // remove 'foo' from the callback list
  11. callbacks.remove( foo );
  12. // fire the items on the list again
  13. callbacks.fire( 'world' );
  14. // nothing output as 'foo' is no longer in the list/code>

还没有评论.