国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

continue loopcontinue

Continue loop continue

Statement structure:

for(初始條件;判斷條件;循環(huán)后條件值更新)
{
  if(特殊情況)
  { continue; }
 循環(huán)代碼
}

In the above loop, when a special situation occurs, this loop will is skipped, and subsequent loops will not be affected. It's like outputting 10 numbers. If the number is 5, it won't be output.

<html>
<head>
    <script>
        var num;
        for(num=1;num<10;num++){
            if (num==5)
            {
                continue;//如果num是5,退出循環(huán)。
            }
            document.write("數(shù)值"+num+"<br />");
        }
    </script>
</head>
<body>
</body>
</html>

The results are as follows:

QQ截圖20161012134926.png

In the above code, the loop with num=5 will be skipped.

<!DOCTYPE html>
<html>
<body>
<p>點(diǎn)擊下面的按鈕來執(zhí)行循環(huán),該循環(huán)會跳過 i=3 的步進(jìn)。</p>
<button onclick="myFunction()">點(diǎn)擊這里</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x="",i=0;
for (i=0;i<10;i++)
  {
  if (i==3)
    {
    continue;
    }
  x=x + "The number is " + i + "<br>";
  }
document.getElementById("demo").innerHTML=x;
}
</script>
</body>
</html>
Continuing Learning
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>continue</title> <script type="text/JavaScript"> var mynum =new Array(70,80,66,90,50,100,89);//定義數(shù)組mynum并賦值 var i; for(i=0;i<mynum.length;i++) { if(mynum[i]<60) { document.write("成績不及格,不輸出!"+"<br>"); continue; } document.write("成績:"+mynum[i]+"及格,輸出!"+"<br>"); } </script> </head> <body> </body> </html>
submitReset Code