Loading a function backwards?

Loading a function backwards?

(I have bad terminology, so please bare with me atm)

Is there a way to load a function, and have it initate each action in reverse.

For example, load this but have the animations start from the last and work to the front? (newBox3 first. Excuse the click method)

  1. $(document).ready(function(){
  2.  
  3.     $("#newBox2").click(function(){
  4.       $("#newBox2").css('z-index', 12).delay(1000).animate({top:'220px'});
  5.       $("#newBox").animate({left:'280px'}).fadeOut(6000);
  6.       $("#newBox3").animate({left:'280px'}).fadeOut(6000);
  7.         });
  8.     });



Also how do I create a plugin or make it so I can reuse the coding. Is it like this?

  1. $.fn.Test = function() {
  2. $("#newBox2").css('z-index', 12).delay(1000).animate({top:'220px'});
  3.       $("#newBox").animate({left:'280px'}).fadeOut(6000);
  4.       $("#newBox3").animate({left:'280px'}).fadeOut(6000);
  5.         });

How do I load it so when a button is clicked initiates that code?

  1. $(document).ready(function(){
  2. $("#newBox2").click(function(Test){
  3. });
  4. });


Thanks. Sorry for the newbie questions