$ .each

时间:2015-11-18 11:07:43

标签: javascript jquery

如果bool变量被定价,我试图打破foreach:

 $.each(GlobalVariables.availableServices, function(index, service) 
 {
       if(state == true){  break;  }
       for (var k = 0; k < appointment.id_services.length; k++)
       {
             if(actual_option == appointment.id_services[k].id)
             {
                 serviceDuration = serviceDuration - parseInt(service['duration']);
                 state = true;
                 break;
              }
         }
 });

但是我收到了这个错误:

  

Uncaught SyntaxError:非法中断语句

在这一行:

if(state == true){  break;  }

为什么会这样?

0 个答案:

没有答案