search
HomeWeb Front-endHTML TutorialWhat event attributes does HTML have?

html event attributes include: onblur, onerror, onfocus, onsubmit, onkeydown, onkeypress, onclick, ondblclick, onmousedown, onmousemove, onmouseout, etc.

What event attributes does HTML have?

HTML Event Properties

Window Event Properties

Events triggered for the window object.

Applies to

Tags:##AttributeValueDescriptiononafterprint#Run the script after printing the documentonbeforeprintRun the script before the document printsonbeforeonloadRun the script before the document loadsonblurRun the script when the window loses focusonerrorRun the script when an error occursonfocusRun script when window gets focusonhaschangeRun script when document changesonloadRun script when document loads onmessageRun script when message is triggered onofflineRun script when document is offlineononlineRun script when document goes onlineonpagehideWhen window is hidden Run scriptonpageshowRun script when window is visibleonpopstateRun script when window history changesonredoRun the script when the document performs a redo operationonresizeRun script when window is resizedonstorageWhen Web Storage area is updated Run the script when (when the data in the storage space changes)onundoWhen the document performs undo Run the scriptonunloadRun the script when the user leaves the document
script
script
script
script
script
script
script
script
script
#script
script
script
script
script
script
script
script
script
script

Form events

Events triggered by actions inside HTML forms.

Applies to all HTML 5 elements, but is most commonly used in form elements:

AttributesValue DescriptiononblurRun script when element loses focusonchangeRun script when element changesoncontextmenuRun script when context menu is triggeredonfocusWhen Run script when element gets focusonformchangeRun script when form changesonforminputScript that runs when the form gets user inputoninputRun script when element gets user inputoninvalidRun script when element is invalid onresetRun when form resets script. onselectRun script when an element is selectedonsubmitRun script when form is submitted
script
script
script
script
script
script
script
script
script HTML 5 is not supported.
script
script

Keyboard events

Events triggered by the keyboard.

Applies to all HTML 5 elements:

AttributesValueDescriptiononkeydownRun script when key is pressedonkeypressRun script when key is pressed and releasedonkeyupRun script when key is released

Mouse events

Events triggered by mouse or similar user actions.

Applies to all HTML 5 elements:

script
script
script
##ondragover Run script when an element is dragged over a valid drag and drop targetondragstartRun script when drag operation startsondropRun script when the dragged element is being draggedonmousedownWhen Run script when mouse button is pressedonmousemoveRun script when mouse pointer movesonmouseoutRun script when the mouse pointer moves out of an element##onmouseoverscriptonmouseupscriptonmousewheelscriptonscrollscript

Multimedia events

Events triggered by media such as video, image, and audio.

Applies to all HTML 5 elements, but is most commonly used in media elements (such as audio, embed, img, object, and video):

Attributes Value Description
onclick script Run script when mouse click
ondblclick script Run the script when the mouse is double-clicked
ondrag script Run script when dragging element
ondragend script Run script when drag operation ends
ondragenter script Script that runs when an element is dragged to a valid drop target
ondragleave #script Script that runs when an element leaves a valid drag and drop target
script
script
script
script
script
script
Run script when mouse pointer moves over element
Run script when mouse button is released
Run the script when the mouse wheel is turned
Run the script when the scroll bar of the element is scrolled
Attribute Value Description
onabort script When an abort event occurs Run the script
oncanplay script Run the script when the media is able to start playing but may need to be stopped due to buffering
oncanplaythrough script Run script when the media is able to play to the end without stopping due to buffering
ondurationchange #script Run script when media length changes
onemptied script Run the script when the media resource element is suddenly empty (network error, loading error, etc.)
onended #script Run script when the medium has reached the end
onerror script Run script when an error occurs during element loading
onloadeddata script Run script when media data is loaded
onloadedmetadata script When the duration of the media element and other media data have been Run script on load
onloadstart script Run script when browser starts loading media data
onpause script Run script when media data is paused
onplay script #Run script when media data is about to start playing
onplaying script Run script when media data has started playing
onprogress script When Run the script when the browser is fetching the media data
onratechange script Run when the playback rate of the media data changes Script
onreadystatechange script Run script when ready-state changes
onseeked #script Script run when the media element's positioning attribute[1] is no longer true and positioning has ended
onseeking #script Run script when the media element's positioning attribute is true and positioning has begun
onstalled script Run script when there is an error (delay) in retrieving media data
onsuspend script Run script when the browser is already retrieving media data but stops before retrieving the entire media file
ontimeupdate script Script that runs when the media changes its playback position
onvolumechange script Run script when the media changes volume or when the volume is set to mute
onwaiting script Run script when media has stopped playing but is intended to continue playing

Other events

Attributes Value Description
onshow script Fired when the element is displayed in context
ontoggle script Triggered when the user opens or closes the
element

For more programming-related knowledge, please visit: Programming Course! !

The above is the detailed content of What event attributes does HTML have?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.