<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>best简单的改变HTML内容</title>
</head>
<body>
<p>段落1</p>
<p>JavaScript:改变 HTML 内容</p>
<h1>标题</h1>
<P id="demo"> HTML的段落标签。
JavaScript能够改变HTML元素的内容</P>
<script>
// f
function myFunction() {
x = document.getElementById("demo");//找到段落里面 ,定义的属性ID 属性值元素
x.innerHTML = "hello JavaScript!";// 改变内容
}
</script>
<button type="button" onclick="myFunction">按钮</button>
</body>
</html>
效果