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://codercto.com/courses/l/35.html

查看所有标签

Programming From The Ground Up

Programming From The Ground Up

Jonathan Bartlett / Bartlett Publishing / 2004-07-31 / USD 34.95

Programming from the Ground Up is an introduction to programming using assembly language on the Linux platform for x86 machines. It is a great book for novices who are just learning to program as wel......一起来看看 《Programming From The Ground Up》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具