这是我的代码
HTML
<body>
<div>
<input type="text" id="id">
<p></p>
</div>
<script src="main.js"></script>
CSS
body{
display: flex;
justify-content: center;
align-items: center;
height: 500px;
}
JavaScript
document.getElementById("id").addEventListener("click", func);
document.getElementsByTagName("body")[0].addEventListener("onmousemove", func);
function func() {
console.log(5)
}
addEventListener适用于“ click”事件,但不适用于“ onmousemove”