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

查看所有标签

Parsing Techniques

Parsing Techniques

Dick Grune、Ceriel J.H. Jacobs / Springer / 2010-2-12 / USD 109.00

This second edition of Grune and Jacobs' brilliant work presents new developments and discoveries that have been made in the field. Parsing, also referred to as syntax analysis, has been and continues......一起来看看 《Parsing Techniques》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具