質問

$(document).ready(function (){
    var x = false;
    $('#board_code').keyup(function(e) {
        if(x)
            callFunc();
    })  
})

function callFunc(){
    if(expression==true)
        x=true;
    else
       x=false;
}

I know i can just put the def of callFunc inside $(document).ready function, but what is the other way so that i wouldnt use global variable

UPDATE: i forgot to put the if(x), check it again. This is for brace matching in my web-based ide project ^^

役に立ちましたか?

解決

$(document).ready(function (){
    var x = false;
    $('#board_code').keyup(function(e) {
        x = callFunc();
    })  
})

function callFunc(){
  return expresion ? true : false;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top