JQuery is indeed a good framework for improving the efficiency of front-end development (although many experts say it is inefficient), but it is sometimes not easy to use it, you may have encountered the following situations: An aspx page can usually contain other ascx controls. If multiple developers work collaboratively, the programmer John is in control. $ () is used in ascx (). ready (function {}), while programmer John is in control B. the ready function is also used in ascx. When Programmers Make A page. ascx, B. ascx is dragged to its own page, and $ () is also required in the page (). ready function:
Although jQuery is still well designed, after the document is loaded, the functions defined in ready are triggered in sequence (this is good, unlike in javascript, functions with the same name will overwrite the previous function definition by default ), but what if a programmer wants to execute his/her ready part first (or when the three programmers each have a strict order of ready processing?
In fact, this is not difficult. You can use setTimeOut to delay the ready part of a programmer.
The Code is as follows:
$ (). Ready (function (){
SetTimeout (Test1, 50); // This function is executed after a delay of 50 milliseconds.
})
$ (). Ready (function (){
Test2 ();
})
Function Test1 (){
Alert (" ");
}
Function Test2 (){
Alert ("www.jb51.net ");
}
Just like this. It should have first popped up 1, then popped up 2. After triggered by latency, it became first popped up 2, then popped up 1