callback回调问题(输出的结果为什么是这样)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://img1.sycdn.imooc.com//down/540812440001e40e00000000.js" type="text/javascript"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
function show(data) {
$("body").append('<li>' + data + '</li>')
}
function fn1(value) {
show("fn1 says: "+value+'</br>');
}
function fn2(value) {
fn1("fn2 says: " + value+'</br>');
return false;
}
function fn3(value) {
fn1("fn3 says: " + value+'</br>');
return false;
}
var callbacks = $.Callbacks();
callbacks.add(fn1);
callbacks.fire("foo!"); //输出fn1 says:foo!
callbacks.add(fn2);
callbacks.fire("too!"); //输出 fn1 says:too! fn1 says:fn2 says:too!
callbacks.add(fn3);
callbacks.fire("bar!"); //输出fn1 says:bar! fn1 says:fn2 says:bar! fn1 says:fn3 says:bar!
</script>
</body>
</html>