JavaScript HTML DOM Events Examples
Examples of using JavaScript to react to events
Input Events
onblur - When a user leaves an input fieldonchange - When a user changes the content of an input fieldonchange - When a user selects a dropdown valueonfocus - When an input field gets focusonselect - When input text is selectedonsubmit - When a user clicks the submit buttononreset - When a user clicks the reset buttononkeydown - When a user is pressing/holding down a keyonkeypress - When a user is pressing/holding down a keyonkeyup - when the user releases a key (1)onkeyup - When the user releases a key (2)onkeydown vs onkeyup - Both
Mouse Events
onmouseover/onmouseout - When the mouse passes over an elementonmousedown/onmouseup - When pressing/releasing a mouse buttononmousedown - When mouse is clicked: Alert which elementonmousedown - When mouse is clicked: Alert which buttononmousemove/onmouseout - When moving the mouse pointer over/out of an imageonmouseover/onmouseout - When moving the mouse over/out of an imageonmouseover an image map
Click Events
Acting to the onclick eventonclick - When button is clickedondblclick - When a text is double-clicked
Load Events
onload - When the page has been loadedonload - When an image has been loadedonerror - When an error occurs when loading an imageonunload - When the browser closes the documentonresize - When the browser window is resized
Others
What is the keycode of the key pressed?What are the coordinates of the cursor?What are the coordinates of the cursor, relative to the screen?Was the shift key pressed?Which event type occurred?

