當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JQuery callbacks.fired()用法及代碼示例

用法
callbacks.fired() => Boolean

說明:確定回調是否已經至少被調用過一次。

  • 添加的版本:1.7callbacks.fired()

    • 此方法不接受任何參數。

例子:

使用 callbacks.fired() 確定列表中的回調是否至少被調用過一次:

// A sample logging function to be added to a callbacks list
var foo = function( value ) {
  console.log( "foo:" + value );
};
 
var callbacks = $.Callbacks();
 
// Add the function "foo" to the list
callbacks.add( foo );
 
// Fire the items on the list
callbacks.fire( "hello" ); // Outputs: "foo: hello"
callbacks.fire( "world" ); // Outputs: "foo: world"
 
// Test to establish if the callbacks have been called
console.log( callbacks.fired() );

相關用法


注:本文由純淨天空篩選整理自jquery.com大神的英文原創作品 callbacks.fired()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。