-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile.html
More file actions
38 lines (38 loc) · 1.04 KB
/
Copy pathwhile.html
File metadata and controls
38 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>while循环语句</h1>
<p id="demo"></p>
<button onclick="myfunction()">运行while循环</button>
<script>
function myfunction() {
const demoElement = document.getElementById("demo");
demoElement.innerHTML = "";
let i = 0;
while (i < 10) {
demoElement.innerHTML += i + " ";
i++;
}
}
</script>
<h2>do while循环语句</h2>
<p id="demo1"></p>
<button onclick="myfunction1()">运行do while循环</button>
<script>
function myfunction1() {
const demoElement = document.getElementById("demo1");
demoElement.innerHTML = "";
let i = 0;
do {
demoElement.innerHTML += i + " ";
i++;
} while (i < 10);
}
</script>
</body>
</html>