jquery dynamic loading of JS three methods

Source: Internet
Author: User
Tags getscript

<!--here to provide you with three kinds of dynamic loading JS jquery instance code Oh, because jquery is to provide users with convenience, so the use of jquery dynamic loading files as long as a word $.getscript ("test.js"); OK.

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>

<title>jquery dynamic loading of JS three methods </title>
<script language= "Web Effects" >
$.getscript ("Test.js"); Method Two

function Loadjs (file) {
var head = $ (' head '). Remove (' #loadscript ');
$ ("<scri" + "pt>" + "</SCR" + "ipt>"). attr ({src:file,type: ' text/javascript ', ID: ' Load '}). Appendto (head);
}//Simple enough! If you're concentrating on the following, you can even use one line of code:
Method Three

$ ("<scri" + "pt>" + "</SCR" + "ipt>"). attr ({src:file,type: ' text/javascript ', ID: ' Load '}). Appendto ($ (' Head '). Remove (' #loadscript '));

</script>

<body>
</body>

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.