源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p id="demo"></p> <script> var cars = ["BMW", "Volvo", "Saab", "Ford"]; var text = ""; list: { text += cars[0] + "<br>"; text += cars[1] + "<br>"; text += cars[2] + "<br>"; break list; text += cars[3] + "<br>"; text += cars[4] + "<br>"; text += cars[5] + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>
运行结果