This is common.js
jQuery(function ($) {
var commonJs = {
init: function () {
},
showAlert: function () {
},
}
});
This is add.js
jQuery(function ($) {
var addJs = {
init: function () {
console.log(commonJs.showAlert);
},
}
});
I want to use common js function commonJs.showAlert in add.js
How can i access that?
This is common.js
jQuery(function ($) {
var commonJs = {
init: function () {
},
showAlert: function () {
},
}
});
This is add.js
jQuery(function ($) {
var addJs = {
init: function () {
console.log(commonJs.showAlert);
},
}
});
I want to use common js function commonJs.showAlert in add.js
How can i access that?
Share Improve this question asked Mar 17, 2020 at 7:01 Shweta DanejShweta Danej 154 bronze badges2 Answers
Reset to default -1Please simply place commonJs var outside the jQuery function and try again. It will work for you.
var commonJs;
jQuery(function ($) {
commonJs = {
init: function () {
},
showAlert: function () {
},
}
});
I just had to put this variable outside jQuery(function ($) and it worked.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744657869a4586289.html
评论列表(0条)