HTML Event Attributes

Last updated: 2026-09-12

HTML Event Attributes

Event attributes bind event handlers directly in HTML, executing JavaScript when a specific event occurs. They can be used on all HTML elements.

Window / Document Events

Event AttributesDescription
onloadFires when the element finishes loading.
onunloadFires when the page unloads.
onresizeFires when the window is resized.
onscrollFires when an element or the page is scrolled.
onerrorFires when a resource fails to load.

Form Events

Event AttributesDescription
onsubmitFires when a form is submitted.
onresetFires when a form is reset.
onchangeFires when an element's value changes and it loses focus.
oninputFires immediately when the element's value changes.
onfocusFires when the element gains focus.
onblurFires when the element loses focus.
onselectFires when text is selected in a text field.

Keyboard Events

Event AttributesDescription
onkeydownFires when a key is pressed down.
onkeyupFires when a key is released.
onkeypressFires when a key is pressed and released (deprecated).

Mouse Events

Event AttributesDescription
onclickFires when the element is clicked.
ondblclickFires when the element is double-clicked.
onmousedownFires when a mouse button is pressed down on the element.
onmouseupFires when a mouse button is released on the element.
onmousemoveFires when the mouse moves over the element.
onmouseoverFires when the mouse enters the element or its children.
onmouseoutFires when the mouse leaves the element or its children.
onwheelFires when the mouse wheel is scrolled over the element.
oncontextmenuFires when the context menu is opened (right-click).

Drag Events

Event AttributesDescription
ondragFires while an element is being dragged.
ondropFires when a dragged element is dropped onto a target.

Clipboard Events

Event AttributesDescription
oncopyFires when content is copied.
oncutFires when content is cut.
onpasteFires when content is pasted.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏