Html 哪些 DOM 事件可以绑定到 DIV 元素?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7284379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:25:29  来源:igfitidea点击:

Which DOM events can be bound to a DIV element?

eventsdomhtml

提问by RedDragon

As per question in the title...

根据标题中的问题...

回答by Richard H

There's a complete list of DOM events here, which includes browser-specific and touch-interface events as well. All the Mouse and Keyboard events can be attached to a div, which are:

有DOM事件的完整列表在这里,其中包括浏览器特定的和触摸界面事件也是如此。所有的鼠标和键盘事件都可以附加到一个 div 上,它们是:

mousedown, mouseup, mouseover, mousemove, mouseout, click, dblclick, keydown, keypress, keyup

mousedown, mouseup, mouseover, mousemove, mouseout, click, dblclick, keydown, keypress, keyup

回答by GSGupta

There are various events which can be performed on divtags such as

可以在div标签上执行各种事件,例如

ondrag,
ondragcenter,
ondragleave,
ondrop,
ondragover,
ondragstart,
ondragend,
onscroll 

回答by Remi

event Attributes you can use:

您可以使用的事件属性:

onclick, ondblclick, onmousedown, onmousemove, onmouseout, 
onmouseover, onmouseup, onkeydown, onkeypress, onkeyup

See more about the <div>tag here, and general DOMevents here.

查看更多有关的<div>标签在这里,和一般的DOM事件在这里