我不熟悉脚本方面,再次需要您的帮助来编写更好的代码。我使用的是init函数,它是所有函数的集合,但现在如果某些条件成立,我似乎不想执行多少函数。
示例脚本
$(document).ready(function() {
var app = {
init: function(){
// Variable to check condition
var abc = 0;
// Default functions
this.Function1();
this.Function2();
this.Function3(); // abc variable will change to 1 if condition is true
// Conditional functions
if ( abc === 1 ) {
this.ConditionFunction1();
this.ConditionFunction2();
},
Function1: function(){ // some Code },
Function2: function(){ // some Code },
Function3: function(){
if(true) { abc == 1; }
},
ConditionFunction1: function(){ // some Code },
ConditionFunction2: function(){ // some Code }
}
app.init();
});