乐趣区

JavaScript学习

JavaScript 基础

javascript 语句可以再 head 中也可以在 body 中,javascript 可以写成函数的形式,在触发事件的时候调用函数就行

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {document.getElementById("demo").innerHTML = "段落被更改。";
}
</script>
</head>

<body>

<h1> 一张网页 </h1>
<p id="demo"> 一个段落 </p>
<button type="button" onclick="myFunction()"> 试一试 </button>

</body>
</html>
退出移动版