如何在html引入jquery
建议直接使用在线前端库,有免费的CDN加速,加载jQuery会更快
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
(function() {
var jsfiles = new Array(
"script/jquery.js",
"script/aaa.js"
);
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
if(docWrite) {
var allScriptTags = new Array(jsfiles.length);
}
var host = "lib/"; //文件的所在目录
for (var i=0, len=jsfiles.length; i<len; i++) {
if (docWrite) {
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
"'></script>";
} else {
var s = document.createElement("script");
s.src = host + jsfiles[i];
var h = document.getElementsByTagName("head").length ?
document.getElementsByTagName("head")[0] :
document.body;
h.appendChild(s);
}
}
if (docWrite) {
document.write(allScriptTags.join(""));
}
})();
试试吧~这个是通过 js引用 JS的方法,需要引用的JS放到数组里就行了 jsfiles
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>