Jquery is indeed a good framework to improve the efficiency of front-end development (although many experts say it is not efficient), 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:ProgramClerk Zhang 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.
$ (). Ready (function () {setTimeout (test1, 50); // this function will be executed after a delay of 50 milliseconds}) $ (). ready (function () {Test2 () ;}) function test1 () {alert ("1") ;}function Test2 () {alert ("2 ");}
In this case, 1 should have been popped up first, and 2 should have been popped up. After a delay trigger is used, 2 will pop up first, and 1 will pop up again.