<div class="codetitle"> <span><a style="CURSOR: pointer" data="10709" class="copybut" id="copybut10709" onclick="doCopy('code10709')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code10709"> <br><!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><head><br><meta http-equiv="content-type" content="text/html; charset=gb2312" /><br><title>jquery 动态加载js三种方法</title><br>//方法一<br><script language="网页特效"><br>$.getscript("test.js"); <br>//方法二<br>function loadjs(file){ <br> var head = $('head').remove('#loadscript');<br> $("<scri" "pt>" "</scr" "ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto(head);<br>}<br>//够简单把!如果在浓缩以下你甚至可以用一行代码全部搞定:<br>//方法三<br>$("<scri" "pt>" "</scr" "ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto($('head').remove('#loadscript'));<br></script><br> </div>