JavaScript & jQuery Tutorials

JQ Home Right Arrow Objects Right Arrow callbacks.add()


Add to the callbacks list.


The callbacks.add() Callbacks object method, allows us to add callback(s) to a callback list.


Signature Description
callbacks.add(callbacks)Add callback(s) to a callback list.


Parameter Description Type
callbacksA function, or array of functions, to be added to the specified callback list.Array



callbacks.add( callbacks ) Example go to Objects Objects   go to top of page Top

Add callback(s) to a callback list.

In the example below when we press the button the first time we add the aFunc(value, div) and bFunc(value, div) functions to our callbacks list and fire them off.

  $('#btn6').one('click', function(){
    var ourCallbacks = $.Callbacks();
    ourCallbacks.add( aFunc ); 'The aFunc function was fired from our callbacks. <br />', '#div6');
    ourCallbacks.add( bFunc ); 'The bFunc function was fired from our callbacks. <br />', '#div6');
  function aFunc( value, div ){
    $(div).append( value);
  function bFunc( value, div ){
    aFunc('Passing bFunc function value to aFunc. <br />', div);

div6. Some initial text.

Press the button below to action the above code:

Related Tutorials

jQuery Advanced Tutorials - Lesson 6 - The Callbacks Object


go to jQuery home page jQ Home go to Objects Objects go to top of page Top