首页 > 解决方案 > 在一个js文件中调用所有jquery文件

问题描述

要在我当前使用的标题上的一行中调用所有 js 文件

function alljs(jsfile) {
    var src = document.createElement("script");
    src.setAttribute("type", "text/javascript");
    src.setAttribute("src", jsfile);
    document.getElementsByTagName("head")[0].appendChild(src);
}

alljs("path/to/my/jsfile1.js");
alljs("path/to/my/jsfile2.js");
alljs("path/to/my/jsfile3.js");

那么我所要做的就是把它放在我的标题上:

<script type="text/javascript" src="my/path/all.js" ></script>

但最近我必须在我的系统中包含 jquery 文件我注意到通过添加调用 jquery 文件

alljs("path/to/my/jqueryfile1.js");

到我的all.js文件不起作用...我必须<script>在标题上做第二行才能调用 jquery 文件...

我的问题是:是否有类似的方法可以在一个文件中调用所有 jquery 文件?

标签: javascriptjquery

解决方案


推荐阅读