addEventListener不适用于onmousemove

问题描述 投票:-1回答:1

这是我的代码

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”

javascript html dom
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.