复制代码 代码如下:
<!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三种方法</title>
//方法一
<script language="网页特效">
$.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);
}
//够简单把!如果在浓缩以下你甚至可以用一行代码全部搞定:
//方法三
$("<scri"+"pt>"+"</scr"+"ipt>").attr({src:file,type:'text/javascript',id:'load'}).appendto($('head').remove('#loadscript'));
</script>
您可能感兴趣的文章:
- 使用jQuery动态加载js脚本文件的方法
- jquery及js实现动态加载js文件的方法
- jquery getScript动态加载JS方法改进详解
- 一个简单的动态加载js和css的jquery代码
- 三种动态加载js的jquery实例代码另附去除js方法
- 如何使用jquery动态加载js,css文件实现代码
- jquery动态加载js/css文件方法(自写小函数)
- 使用jquery动态加载Js文件和Css文件
- 使用jquery动态加载javascript以减少服务器压力
- 使用jquery动态加载js文件的方法
- jQuery实现动态加载(按需加载)javascript文件的方法分析