how to execute jquery functions in a order?

后端 未结 3 1254
梦如初夏
梦如初夏 2021-01-26 16:52

As the title says, how can I maintain/control the order of execution of functions in Jquery? I know we can establish many event handler via addEventListener, but th

3条回答
  •  情深已故
    2021-01-26 17:13

    I could use callback functions and handle events in these functions.

    function helloWorld(hello,callback)
    {
       //does something here with hello 
       callback(); //calls the callback function for final execution
    }
    
    helloWorld("world",alertUser);
    
    function alertUser(){
      alert("I am done with this function");
    }
    

    So if I understood your question OK, then I do something like the above.

提交回复
热议问题