[英]call a function inside a function from another function
I'm using jquery and in my app.js file I have tow main functions: 我正在使用jquery并且在我的app.js文件中有两个主要功能:
my code looks like this: 我的代码如下所示:
$(function () { // code // code function myFunction(){ // code } }); $(window).on("load", function () { // I want to use myFunction() here but I cant because it's not accessible from here myFunction(); });
is there a way to do this? 有没有办法做到这一点?
window.lib = {
onWindowLoad: function () {
...
},
onDocReady: function() {
...
},
evenmore: {
nested: function(){
...
}
}
}
$(window).on("load", function () {
lib.onWindowLoad();
});
There would be many other ways to do so. 还有许多其他方法可以做到这一点。
In case, if you need to read something somewhere, that's here 如果您需要在某处阅读某些内容, 那就在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.