Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <script src="http://cdn.static.w3big.com/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <script> $(function () { $(function () { // 一个将被添加到列表的简单的函数 var foo = function( value ) { alert( value ); }; var callbacks = $.Callbacks(); // 添加上面的函数到回调列表 callbacks.add( foo ); // 传入参数调用所有回调列表函数 callbacks.fire( "foo" ); // 输出: foo // 禁用回调函数 callbacks.disable(); // 尝试用 "foobar" 作为参数 callbacks.fire( "foobar" ); // foobar 不会被输出 }) }) </script> </body> </html>