Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 HTML 页面,我想像按钮一样使用页面,例如,当我单击页面上的任意位置时,发生的事情就像按钮一样,无论如何?
click将document事件处理程序绑定到对象。
click
document
document.addEventListener('click', function (evt) { alert('click'); });
当鼠标单击页面上的任意位置时,您可以使用以下函数触发操作:
document.body.onmousedown = function() { // enter your code here }