W3Schools.com

HTML DOM Event Object


Event Object

Events are actions that can be detected by JavaScript, and the event object gives information about the event that has occurred.

Sometimes we want to execute a JavaScript when an event occurs, such as when a user clicks a button.

Events are normally used in combination with functions, and the function will not be executed before the event occurs.


Event Attributes

Below is the event attributes that can be inserted into different HTML elements to define event actions.

W3C: W3C Standard.

Attribute Description W3C
onblur The event occurs when an element loses focus Yes
onchange The event occurs when the content of an element, the selection, or the checked state have changed Yes
onclick The event occurs when the user clicks on an element Yes
ondblclick The event occurs when the user double-clicks on an element Yes
onerror The event occurs when an error occurs while loading an external file Yes
onfocus The event occurs when an element gets focus Yes
onkeydown The event occurs when the user is pressing a key or holding down a key Yes
onkeypress The event occurs when the user is pressing a key or holding down a key Yes
onkeyup The event occurs when a keyboard key is released Yes
onload The event occurs when an object has been loaded Yes
onmousedown The event occurs when a user presses a mouse button over an element Yes
onmousemove The event occurs when a user moves the mouse pointer over an element Yes
onmouseout The event occurs when a user moves the mouse pointer out of an element Yes
onmouseover The event occurs when a user mouse over an element Yes
onmouseup The event occurs when a user releases a mouse button over an element Yes
onresize The event occurs when the size of an element has changed Yes
onselect The event occurs after some text has been selected in an element Yes
onunload The event occurs before the browser closes the document Yes

Event Properties

Property Description W3C
altKey Returns whether or not the "ALT" key was pressed when an event was triggered Yes
attrChange    
attrName    
bubbles Returns a Boolean value that indicates whether or not an event is a bubbling event Yes
button Returns which mouse button was clicked when an event was triggered Yes
cancelable Returns a Boolean value that indicates whether or not an event can have its default action prevented Yes
cancelBubble    
charCode    
clientX Returns the horizontal coordinate of the mouse pointer, relative to the current window, when an event was triggered Yes
clientY Returns the vertical coordinate of the mouse pointer, relative to the current window, when an event was triggered Yes
ctrlKey Returns whether or not the "CTRL" key was pressed when an event was triggered Yes
currentTarget Returns the element whose event listeners triggered the event Yes
data    
dataTransfer    
detail    
dropEffect    
effectAllowed    
eventPhase Returns which phase of the event flow is currently being evaluated Yes
keyCode    
metaKey Returns whether or not the "meta" key was pressed when an event was triggered Yes
newValue    
origin    
relatedNode    
relatedTarget Returns the element related to the element that triggered the event Yes
pageX    
pageY    
prevValue    
screenX Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was triggered Yes
screenY Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was triggered Yes
shiftKey Returns whether or not the "SHIFT" key was pressed when an event was triggered Yes
source    
srcElement    
target Returns the element that triggered the event Yes
timeStamp Returns the time stamp, in milliseconds, from the epoch (system start or event trigger) Yes
toElement    
type Returns the name of the event Yes
view    
wheelDelta    
which    



W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Create a Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE