我想输出鼠标指针元素的数量:
<p>some text here</p>
<span>number of hovered elements: </span><span id="debugElement"></span>
<script>
var debugElement = document.getElementById("debugElement");
window.addEventListener("mousemove", (event) => debugElement.innerHTML = document.querySelectorAll(":hover").length);
</script>
上面的代码在JsFiddle上按预期工作: https://jsfiddle.net/n4vreycp/1/
但不是在本地执行。