jquery动态加载js三种方法实例

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

jquery动态加载js三种方法实例

  2020-05-13 我要评论
复制代码 代码如下:

<!doctype html public "-//w3c/https://img.qb5200.com/download-x/dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1https://img.qb5200.com/download-x/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>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们