代码示例:(标识:jsck_document_queryselector)
<!DOCTYPE html>
<html>
<body>

<h1>Document 对象</h1>

<h2>querySelector() 方法</h2>

<p>更改 id="demo" 元素的文本:</p>

<p id="demo">这是 id="demo" 的 p 元素。</p>

<script>
document.querySelector("#demo").innerHTML = "Hello World!";
</script>

</body>
</html>
运行结果: