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
Building Websites with Joomla!
H Graf / Packt Publishing / 2006-01-20 / USD 44.99
This book is a fast paced tutorial to creating a website using Joomla!. If you've never used Joomla!, or even any web content management system before, then this book will walk you through each step i......一起来看看 《Building Websites with Joomla!》 这本书的介绍吧!