DOM Events

What is DOM?

  • Document Object Model.
  • The HTML represented as an object.
    
    							document.getElementById('id')
    						

DOM Events

  • Events trigger when certain criteria are met.
  • Such as a click, mouse over, key press, on load.
  • You can tie these events to functions that you create that will be run when the event triggers.
    Click me!
    
    
    Click me!

Triggers

Mouse Events

  • click
  • contextmenu
  • dblclick
  • mousedown
  • mouseenter
  • mouseleave
  • mouseout
  • mouseover
  • mouseup

Keyboard Events

  • keydown
  • keypress
  • keyup

Drag Events

  • drag
  • dargend
  • dragenter
  • dragover
  • dragleave
  • dragstart
  • drop

Focus Events

  • focus
  • blur

Touch Events

  • touchstart
  • touchmove
  • touchend
  • touchcancel

Event Handling Models

  • inline.
  • traditional.
  • W3C.

Inline Event Handling Model

							
								
							

Don’t recommend embedding events directly in page elements!

Traditional Event Handling Model

							
								
								
							

W3C Event Handling Model

							
								
								
							

Event Object

All event objects in the DOM are based on the Event Object.

							
								
								
							

Event Target

The target event property returns the element that triggered the event.

							
								
								
							

Event Methods

preventDefault

							
Vkontakte

							
					

stopPropagation

						
Hi