Web pages are much more than just static displays of text and graphics. JavaScript gives web pages interactivity and the ability to perform useful work. An important part of JavaScript’s ability to perform useful functions in the browser is its ability to respond to events.
Here is a list of common events that happen in web browsers that JavaScript can respond to.
Event | Occurs When . . . |
---|---|
abort | The loading of a file is aborted. |
blur | An element has gone out of focus. In other words, the element is no longer the thing that the user is focusing on. |
change | An element’s value has changed since losing and regaining focus. |
click | A mouse has been clicked on an element. |
dbclick | A mouse has been clicked twice on an element. |
error | A file failed to load. |
focus | An element has come into focus. In other words, the element is what the user is currently focusing on. |
input | The value of an or element is changed. |
keydown | A key is pressed down. |
keyup | A key is released after being pressed. |
load | A file and its attached files have finished loading. |
mousedown | A mouse button has been pressed down on an element. |
mouseenter | A mouse pointer is moved onto the element that has the listener attached. |
mouseleave | A mouse pointer is moved off the element that has the listener attached. |
mousemove | A mouse pointer is moved over an element. |
mouseout | A mouse pointer is moved off the element or one of its children that has the listener attached. |
mouseover | A mouse pointer is moved onto the element or one of its children that the listener is attached to. |
mouseup | A mouse button is released over an element. |
mousewheel | A wheel button of a mouse is rotated. |
reset | A form is reset. |
resize | The document has been resized. |
scroll | The document or an element has been scrolled. |
select | Text has been selected. |
submit | A form is submitted. |