Jquery ready function tester.

Source: Internet
Author: User
ArticleDirectory
    • Loading 1...
    • Loading 4! To end!
    • Document. Ready 1!
    • Document. Ready 2!

 

During development, it is inevitable that a script is inserted in the middle of the html body. Many colleagues often encounter this or that problem. The problem is simple. Some scripts can be executed only after the file (DOM) is loaded, the script inserted in the body (except for jquery. delayed execution of scripts such as readyCode) Is executed in the document loading (from top to bottom). jquery solves the problem of loading scripts in the document. The ready function is very convenient after the file is loaded and executed.

This article mainly solves problems encountered by many colleagues and reminds them not to make similar mistakes.

 

Test source code:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <br/> <pead> <br/> <title> jquery ready function tester. </title> <br/> <MCE: script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" mce_src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </MCE: S Scripts> <br/> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> function writeln (s) {$ ("body "). append ("<p>" + S + "</p> "). append ("<br/>") ;}< br/> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body> <br/> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> writeln ("loading 1... "); <br/> // --> </MCE: SCRIPT> <br/> <MCE: Script Type =" text/JavaScript "> <! -- </P> <p> $ (document). Ready (function () {writeln ("document. Ready 1! ") ;}); <Br/> writeln (" loading 2... "); <br/> // --> </MCE: SCRIPT> <br/> <MCE: Script Type =" text/JavaScript "> <! -- <Br/> $ (document). Ready (function () {writeln ("document. Ready 2! ") ;}); <Br/> writeln (" loading 3... "); <br/> // --> </MCE: SCRIPT> <br/> <MCE: Script Type =" text/JavaScript "> <! -- <Br/> writeln ("loading 4! To end! "); <Br/> // --> </MCE: SCRIPT> <br/> </body> <br/> </ptml> <br/>

 

Test results:

 

Loading 1...

 

Loading 4! To end!

 

Document. Ready 1!

 

Document. Ready 2!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.