梦入琼楼寒有月,行过石树冻无烟

JavaScript 显示与弹出

显示JavaScript内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script>
function textDate() {
document.write("<h1>你好世界,HellO,world!</h1>")
}
</script>
</head>
<body>

<h1>点击按钮切换内容</h1>

<button type="button" onclick="textDate()">Go!</button>

</body>
</html>

弹出JavaScript内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
<script>
function textDate() {
alert("暂停维护!")
}
</script>
</head>
<body>

<h1>点击按钮切换内容</h1>

<button type="button" onclick="textDate()">Go!</button>

</body>
</html>

插入body

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Demo</title>
</head>
<body>

<h1>当前时间为:</h1>
<script>document.write(Date());</script>
</body>
</html>
ID DA FA
write 输出文字 document
alert 弹窗提示 alert
⬅️ Go back