利用jquery动态加载文件很方便,使用$.getscript("test.js");就可以了。
例1,动态加载js的jquery实例代码。
 
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=gb2312" /> 
<title>jquery 动态加载js三种方法 - www.jb200.com</title> 
<script language="javascript"> 
$.getscript("test.js");
//方法二 
function loadjs(file){ 
var head = $('head').remove('#loadscript'); 
$("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto(head); 
}
//一行代码搞定js代码加载: 
//方法三 
$("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto($('head').remove('#loadscript')); 
</script> 
</head> 
<body> 
</body> 
</html>
例2,jquery去除js