如何使用jQuery从另一个文件调用JavaScript函数 [英] How to use jQuery to call a JavaScript function from another file
本文介绍了如何使用jQuery从另一个文件调用JavaScript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题:
我有2个文件:
//Sub.js函数Second(){//在这里做点事}//Main.js函数One(){//在这里做点事}$(function(){第二();});
因此,基本上,功能秒太长了;因此,我想将其移至 Sub.js 文件并从 Main.js 进行调用.问题在于必须在功能之后执行该功能(功能Second ),因为它从功能One 输出中获取了一些数据.>
我不知道该怎么做,请帮忙.
解决方案
如果您特别想使用jQuery,
$.getscript("Sub.js",function(){第二();});
My question:
I have 2 files:
//Sub.js
function Second() {
//do something here
}
//Main.js
function One() {
//do something here
}
$(function() {
Second();
});
So basically, the function Second is too long; therefore, I want to move it to a Sub.js file and call it from the Main.js. The problem is this function ( function Second) has to be executed after function One because it gets some data from the function One output.
I don't know how to do this, please help.
解决方案
If you specifically want to use jQuery,
$.getscript("Sub.js",function(){
Second();
});
这篇关于如何使用jQuery从另一个文件调用JavaScript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文