方法很简单,这里就不多废话了,直接奉上代码:
复制代码 代码如下:
$.extend({
includePath: '',
include: function(file) {
var files = typeof file == "string" "");
var att = name.split('.');
var ext = att[att.length - 1].toLowerCase();
var isCSS = ext == "css";
var tag = isCSS "link" : "script";
var attr = isCSS " type='text/css' rel='stylesheet' " : " language='javascript' type='text/javascript' ";
var link = (isCSS "href" : "src") + "='" + $.includePath + name + "'";
if ($(tag + "[" + link + "]").length == 0) $("body").append("<" + tag + attr + link + "></" + tag + ">");
}
}
});
//使用方法
$.includePath = '../js/Exam';
$.include(['/AddQuestion.js']);
小伙伴们如果有什么疑问就在下面留言吧,大家共同进步。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!