COMP 1537 - Week 8 - DOM Creating, And Events (3)
COMP 1537 - Week 8 - DOM Creating, And Events (3)
There are event types for various different things that happen
Mouse events – mouse click, mouse over, etc.
Key events – key pressed, key down, key up, etc.
Window events – page finished loading, etc.
Form events – user attempted to submit, etc.
Clipboard events – user copied/pasted, etc.
Media events – media data is loaded, etc.
For more on each of the event types, see:
https://developer.mozilla.org/en-US/docs/Web/Events
Element addEventListener:
element.addEventListener(event, function,
useCapture);
Where:
Element is a DOM element (e.g., div)
Event is an event (e.g., click)
Function is a defined function, could be a(n):
Anonymous function expression
Function declaration
useCapture: true or false
Capture is at the beginning of the event
Bubble is at the end of the event
https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Mod
el/Introduction
https://developer.mozilla.org/en-US/docs/Web/API/Document_object_mod
el
https://
developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events
https://developer.mozilla.org/en-US/docs/Web/Events
https://
developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
https://
www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#
Events-phases