代码示例:(标识:jsck_document_activeelement)
<!DOCTYPE html>
<html>
<body onclick="myFunction()">

<h1>Document 对象</h1>

<h2>activeElement 属性</h2>

<input type="text" value="一个输入字段">

<button>一个按钮</button>

<p>单击文档中的任意位置可显示活动元素:</p>

<p id="demo"></p>

<script>
function myFunction() {
  const element = document.activeElement.tagName;
  document.getElementById("demo").innerHTML = element;
}
</script>

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