<!DOCTYPE html>
<html>
<title>基础教程(div.cn)</title>
<head>
<script>
function myFunc() {
document.getElementById("output").innerHTML = "Hello World";
}
</script>
</head>
<body>
<h2>JavaScript在Head中</h2>
<button type="button" onclick="myFunc()">Click</button>
<p id="output">这是一个段落</p>
</body>
</html>