#事件对象 (Event)
Div.onclick = function (event) {
Console.log (event);
Let E = event| | window.event; Resolve compatibility
}
# #事件对象的属性
1) Target object: E.target (Gets the element that triggered the event)
2) This points to the bound element
# # #鼠标相关的属性
1) coordinates relative to the browser (document display area): ClientX, ClientY
2) relative to the page coordinates: PageX, pagey; if there is a scrollbar, the hidden coordinates are calculated
3) relative to the screen coordinates: ScreenX, ScreenY
4) coordinates relative to event Source: OffsetY, OffsetX
# # #键盘相关的属性
1) KeyCode: Key value code, character code, enter key value code is 13
# #事件对象的方法
1) Block Event flow
E.stoppropagation ();
2) The default behavior of blocking events (for example: A tag comes with the jump function)
A.onclick = function (e) {
E.preventdefault ();
}
Ie:
1) Block Event flow
E.cancelbubble = true;
2) default behavior for blocking events
E.returnvalue = false;
# #事件委托
1) Vernacular version: The things to be done by the class entrusted to the ancestors of the elements to do
2) Official version: Event delegation, the actual use of event bubbling principle, the specific sub-node operation, delegated to the gendarme range of ancestor node to deal with
JS Events Object (event)