How to call outer function's return from inner function?

后端 未结 4 1015
抹茶落季
抹茶落季 2020-12-15 03:05

I have such code:

function allValid() {
    $(\'input\').each(function(index) {
        if(something) {
            return false; 
        }    
    });

            


        
4条回答
  •  余生分开走
    2020-12-15 03:30

    Yeah, store it in a local variable.

    function allValid() {
      var allGood = true;
      $('input').each(function (index) {
        if (something) {
          allGood = false;
        }
      });
    
      return allGood;
    }
    

提交回复
热议问题