◆繰り返しを強制的に終了する(break)。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>繰り返し処理を強制的に終了させたい</title>
</head>
<body>
<p>◆繰り返しを強制的に終了する(break)。</p>
<script type="text/javascript">
<!--
i = 1;
while(i < 11) {
document.write(i , "<br>");
if(i == 7) {
break;
}
i++;
}
document.write("<br>" , i , "で強制的にループを終了しました。<br>");
//-->
</script>
</body>
</html>