| jQuery tutorial |
| 1 | The problem with the above example is that myCallBack('foo', 'bar') is evaluated before being passed as a function. Javascript and by extension jQuery expects a function pointer in cases like these. I.E. setTimeout function. In the below usage, an anonymous function is created (just a block of statements) and is registered as the callback function. Note the use of 'function(){'. The anonymous function does exactly one thing: calls myCallBack, with the values of 'foo' and 'bar'. |
Комментарии