The Document Object Model event is a way of handling events and providing information about these events to the script. It provides a set of instructions for a standard way of determining what generated an event, what type of event it was, and when and where the event occurred in the document.
Dom Event Handlers
Inline HTML Attributes
When the vents occur, if you want to execute a bunch of code, you can put all codes together in a function and call for the execution.
Mouse Over Here !!
Click Here !!
Double Click Here !!
More Event Models
The Document Object Model standard provides a large number of events and they can be grouped into six major categories:
MouseEvents : click, mousedown, mouseup, mousemove, etc.
KeyboardEvents : keypress, keydown, and keyup
HTMLEvents : load, error, resize, scroll, etc.
Form events : select, change, submit, reset, focus, etc.
UIEvents : focusin and focusout.
MutationEvents : DOMNodeInserted, DOMAttrModified, etc.
DOM Level 2 Event Handlers
The best approach to work with browser events is to use the event listener way stated in DOM Level 2, where you can have many functions listening to an event. When the event fires, all functions are executed.
DOM Level 2 Event Handlers provides for that is the addEventListener() method, which takes three arguments:
1. An event type argument: click, dblclick, mouseover, keypress, etc.
2. A listener argument: the code to execute when the event happens.
3. An optional Boolean phase parameter: that instructs the event handler to execute either during bubbling phase (default , false) or capture phase (true).