문제

$(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