JavaScript Basics combing - Event

event

1) a specific interaction event is instantaneous document or browser window.

Interaction between JavaScript and HTML is achieved by the event.

2) the flow of events - describes the sequence of events from the page to accept

IE-- event bubbling stream

Netscape-- event capture stream

3) event bubbling: the event is received by most the most specific element (the deepest nesting level which nodes in the document) and then progressively spread upward to the least specific of which node (the document).

click event trigger input, it will take up a level, until rising to the document

Click the button to trigger not only the button, also triggers div, body until the document

4) event capture: less specific node should be received earlier event, and the most specific node last received event.

Event receiver sequence: document-> html-> body-> div-> input

 

Using an Event Handler

1.HTML event handler

2.DOM0-level event handler

Which is the more traditional way: trying to assign a function to an event handler attributes used more advantage of the method is simple cross-browser

3.DOM2-level event handler

DOM2-level event handler

DOM2-level events defines two methods:

Specified for operation processing and removing event handlers

addEventListener()和removeEventListner()。

Three parameters: the name of the event to be processed, as the event handler functions and Boolean values

Boolean value = true, the capture phase calling the event handler 

Boolean value = false, the bubbling stage of the event handler calls

Guess you like

Origin www.cnblogs.com/songsongblue/p/11605779.html