Chapter 9: event
1. DOM event stream
Dom supports two types of event models: Bubble event and capture event.
bubble events: events are triggered in the order of the least specific event targets.
capture event: the opposite process.
2. event processing function/listener function
click, load, Mouseover...
event processing function: A function used to respond to an event call. Dom is called an event listening function.
two allocation methods: In JavaScript or in HTML.
javascript:
var odiv = document. getelementbyid ("div1");
odiv. onclick = function () {
alert ("I was clicked");
}< br> in HTML:
3. in IE, each element and window object have two methods:
attachevent (): Add a processing function.
detachevent (): remove the handler.
4.dom< br> addeventlistener (): assigns a handler.
removeevetlistener (); remove the handler.
example:
[object]. addeventlisteners ("click", fnclick, false);
var fnclick = function () {
alert ("clicked");
}< br> 5. event object
the object that causes the event.
mouse information when an event occurs.
keyboard information when an event occurs.
6. Locate
event object
obtain the event type: oevent. type
obtain the Code : keydown. You can use oevent for keyup. keycode; obtain the key code
7. event Type:
mouse event: Click, dbclick, mousedown, Mouseover ....
Keyboard Events: keydown, keypress, keyup ..
HTML events: load, error, change, submit, resize, focus, blur ....
mutation event: