Event Attributes
This reference covers event attributes that would be used to capture an event, and trigger an action with a client-side scripting language such as JavaScript.
A note of caution, though. You might intend to apply any of these inline event handlers like so:
<span onmouseover="showhoverhelp">view details</span>
However, this is no longer a recommended technique, as it mixes the document’s structure and content (the HTML) with the behavior (JavaScript). The preferred option is to use unobtrusive JavaScript, which negates the need for inline event handlers of this type, and keeps the document structure and content layers separate from its behavior.
In this Section
- onblur
captures the moment that this element loses focus - onchange
captures the moment when the value of this element is changed - onclick
captures a mouse click on the element - ondblclick
captures a double mouse click on this element - onfocus
captures the moment that this element receives focus, either via the cursor or keyboard navigation - onkeydown
captures the event in which a key pressed down (but not released) while focus is on the element - onkeypress
captures a key press while focus is on this element - onkeyup
captures the moment at which a pressed key is released while focus is on the element - onload
catches the point at which a page has completely loaded - onmousedown
captures the pressing down of the mouse button while the cursor is positioned over the element - onmousemove
captures a mouse movement within this element - onmouseout
captures the movement of a cursor off an area covered by this element - onmouseover
captures the movement of a cursor into an area covered by this element - onmouseup
captures the release of a previously pressed mouse button while the cursor is over the element - onreset
captures the moment that this form’s Reset button is activated - onselect
captures the event in which the user selects, or highlights, text in the element - onsubmit
captures the moment that the form element to which this attribute is applied is submitted - onunload
catches the point at which a page has unloaded