一、JavaScript跳转语句
1.break
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<!DOCTYPE html>
<html lang=
"en"
>
<head>
<meta charset=
"UTF-8"
>
<title>Title</title>
</head>
<body>
<script>
for
(
var
i=0; i<10; i++){
if
(i==5){
break
;
}
document.write(
"i="
+i+
"<br/>"
);
}
</script>
</body>
</html>
|
2.continue
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
<!DOCTYPE html>
<html lang=
"en"
>
<head>
<meta charset=
"UTF-8"
>
<title>Title</title>
</head>
<body>
<script>
for
(
var
i=0; i<10; i++){
if
(i==5){
continue
;
}
document.write(
"i="
+i+
"<br/>"
);
}
</script>
</body>
</html>
|
注意:上例中的continue语句打印输出的内容中没有"i=5"这一项!
本文转自yeleven 51CTO博客,原文链接:http://blog.51cto.com/11317783/1791899