运行结果尺寸: 300 x 150
x
 
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  border: 1px solid black;
}
</style>
</head>
<body>
<div id="myDIV">
  <p>这是 div 中的一个 p 元素。</p>
  <p>这也是 div 中的一个 p 元素。</p>
</div>
<p>单击该按钮可更改 div 中第一个 p 元素的文本。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
  var x = document.getElementById("myDIV");
  x.querySelector("p").innerHTML = "Hello World!";
}
</script>
</body>
</html>
×

报个问题: