jQuery callbacks.add() 方法
jQuery 教程
· 2019-03-29 14:59:23
实例
添加函数到回调函数列表
$(function () {
var foo = function( value ) {
alert( "foo: " + value );
};
// 另一个函数将被添加到列表
var bar = function( value ){
alert( "bar: " + value );
};
var callbacks = $.Callbacks();
// 添加函数 "foo" 到列表
callbacks.add( foo );
// 传入参数调用所有回调列表函数
callbacks.fire( "hello" );
// 输出: "foo: hello"
// 添加函数 "bar" 到列表
callbacks.add( bar );
// 传入参数调用所有回调列表函数
callbacks.fire( "world" );
// 输出:
// "foo: world"
// "bar: world"
})
定义和用法
callbacks.add() 函数用于在回调列表中添加一个回调或回调的集合。
提示:此方法返回一个回调对象到它绑定的回调列表。
语法
callbacks.add( callbacks )
参数 | 描述 |
---|---|
callbacks | Function,Array类型 一个函数或者一个函数数组,用来添加到回调列表 |
点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html
The Black Box Society
Frank Pasquale / Harvard University Press / 2015-1-5 / USD 35.00
Every day, corporations are connecting the dots about our personal behavior—silently scrutinizing clues left behind by our work habits and Internet use. The data compiled and portraits created are inc......一起来看看 《The Black Box Society》 这本书的介绍吧!