Original: http://www.cnblogs.com/songyaqi/p/5204143.html
- In the function that triggers the event, we receive an event object, through which we need some parameters, for example, if we need to know who the event is for, we can get it through the property of event
target
(ie aside), Or you can block the default behavior of the browser by means of a method preventDefault()
. Here are some properties and methods of the event object
Properties |
Description |
altkey |
|
button |
|
clientx |
|
clienty |
|
ctrlkey |
|
metakey |
|
relatedtarget |
|
screenx |
|
screeny |
|
shiftkey |
|
IE
Properties (in addition to the mouse/event properties above, IE also supports the following properties)
Properties |
Description |
cancelbubble |
|
fromelement |
|
keycode |
|
offsetx,offsety |
|
returnvalue |
If this property is set, its value is higher than the return value of the event handle. Set this property to |
srcelement |
|
toelement |
|
x,y |
|
- The standard event attribute lists the properties defined by the Level 2 DOM event standard.
Properties and Methods |
Description |
Bubbles |
Returns a Boolean value that indicates whether the event is a bubbling event type. |
cancelable |
Returns a Boolean value that indicates whether the event can hold a default action that can be canceled. |
currentTarget |
Returns the element whose event listener triggered the event. |
Eventphase |
Returns the current stage of event propagation. |
target |
Returns the element that triggered this event (the target node of the event). |
TimeStamp |
Returns the date and time the event was generated. |
type |
Returns the name of the event represented by the current event object. |
Initevent () |
Initializes the properties of the newly created Event object. |
preventDefault() |
Notifies the browser not to perform the default action associated with the event. |
stopPropagation() |
No more events are being dispatched. |
JavaScript Events Object (Event object)