Search code examples
jqueryfunctionsequential

jQuery Sequential Functions


I'm looking to run multiple jQuery functions one after another. There are several threads about this but they only ever seem to show how two functions are done. My second function doesn't seem to execute. Where have I slipped up? http://jsfiddle.net/BSYDv/

$(document).ready( 
    function(){  
        $(function() { alert("1")}, 
          function() { alert("2")}, 
          function() { alert("3")}
         );                     
    });

Solution

  • You could write it like this using auto-called anonymous functions:

    http://jsfiddle.net/BSYDv/2/

    $(document).ready( 
        function(){ 
              (function() { alert("1")})(), 
              (function() { alert("2")})(), 
              (function() { alert("3")})();                     
    });