admin管理员组

文章数量:1421196

How do you do this? like PHP has call_user_func

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

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

How do you do this? like PHP has call_user_func

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

...
plete: function(){ 
  // do_something 
  call_function(my_callback); // here need to call my_callback
}
...
Share Improve this question asked Jun 26, 2011 at 3:52 EdithEdith 31 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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/en/JavaScript/Reference/Global_Objects/Function/Call

本文标签: jquerymanually call a function in javascriptStack Overflow