简体   繁体   English

不能让我的foor循环工作

[英]Cant get my foor loop working

Why isn't this working? 为什么这不起作用?

 var i = 0; for (i < 1) { if ($(".button[name=commit]").val() == "remove"){ i = 1; } } 

I get this error message saying: unexpcted token ) at line 2 . unexpcted token ) at line 2收到此错误消息,说: unexpcted token ) at line 2

Here you go with a solution using while loop 在这里,您可以使用while循环解决方案

var i = 0;
while (i < 1) {
  if ($(".button[name=commit]").val() == "remove"){
    i = 1;
  }
}

Here you go with a solution using for loop 在这里,您可以使用for循环的解决方案

for (var i=0; i<1;) {
  if ($(".button[name=commit]").val() == "remove"){
    i = 1;
  }
}

Hope this will help you. 希望这会帮助你。

while(!$(".button[name=commit]").val() == "remove");

它不起作用,因为for()需要3个命令:初始化,保护和最后一个动作: for(init;guard;action)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM