时间:2021-07-01 10:21:17 帮助过:4人阅读
/*
* LOADScript Mod
* Params url1,url2,url3,url4,fn
*/
jQuery.extend({
loadMod: function(){
var argleng = arguments.length,
arglast = arguments[argleng-1],
fn = false,
queue = [],
checknum = 0,
timer = null
// init
if(jQuery.isFunction(arglast)){argleng = argleng -1;fn=arglast;}
for (var i=0;i<argleng ;i++){
queue.push(arguments[i]);
}
// getscript
jQuery.each(queue,function(i,o){
jQuery.getScript(o);
});
// check load ready?
loadReady();
function loadReady(){
if(jQuery.tools != undefined){
checknum = 0;
$.each(jQuery.tools,function(i,n){
if(jQuery.isPlainObject(n)){checknum++;}
});
}
if(checknum != argleng){
clearTimeout(timer);
timer = setTimeout(loadReady, 100);
}else{
if(!!fn){fn.call(document.jQuery)}
}
}
}
});
// 使用方法
$.loadMod('a.js','b.js','c.js',function(){
alert('success!');
});