0

How do you do this? like PHP has call_user_func

I'm trying to pass a callback function to jQuery.animate(), like this

...
complete: function(){ 
  // do_something 
  call_function(my_callback); // here need to call my_callback
}
...

1 Answer 1

7

You can simply call it like you would any function

 my_callback();

JavaScript also has a call method that some people prefer

 my_callback.call();

Here's a link I found with some extra information regarding the call method. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/Call

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah certain functionalities in php were definitely an after thought. :P Its definitely makes more sense in js, but that is just my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.