<html>
<head>
<title>学习javascript语言(语法)</title>
<link rel="stylesheet" href="table.css">
</head>
<body>
<h3>111111111111</h3>
<script type="text/javascript">
//循环: for , while , do-while
var sum = 0;
for (var i = 1; i <= 100; i++) {
sum += i;
}
document.write("sum=" + sum);
var x = 1;
sum = 0;
while (x <= 100) {
sum += x;
x++;
}
document.write("<br/><font color='#ff0000'> sum2=" + sum + "</font><br>");
</script>
<a href="http://www.baidu.com">百度一下</a>
<br/>
<script type="text/javascript">
//转移语句: break, continue , return
a: for (var x = 0; x < 3; x++) {
for (var y = 0; y < 4; y++) {
document.write("x=" + x + " ");
break a;
}
document.write("<br/>");
}
</script>
</body>
</html>
js---javaScript(循环语句的使用实例)for while do....while(转移语句): break, continue , return
最新推荐文章于 2024-01-01 16:03:52 发布