Event 代表事件状态, 如事件发生的元素, 键盘状态, 鼠标位置和鼠标按钮状态。
一旦事件发生 , 便会生成 Event 对象,如单击一个按钮,浏览器的内存中就产生
相应的 event 对象。
event 对象只在事件发生的过程中才有效。
event 的某些属性只对特定的事件有意义。 比如,fromElement 和 toElement 属
性只对 onmouseover 和 onmouseout 事件有意义。
【event 属性】 :
altKey, button, cancelBubble, clientX, clientY, ctrlKey, fromElement,
keyCode, offsetX, offsetY, propertyName, returnValue, screenX, screenY,
shiftKey, srcElement, srcFilter, toElement, type, x, y
---------------------------------------------------------------------
-----------
1. altKey
描述:检查 alt 键的状态。
语法: event.altKey
可能的值:
当 alt 键按下时,值为 TRUE ,否则为 FALSE 。只读。
2. button
描述:检查按下的鼠标键。
语法: event.button
可能的值:
0 没按键
1 按左键
2 按右键
3 按左右键
4 按中间键
5 按左键和中间键
6 按右键和中间键
7 按所有的键
这个属性仅用于 onmousedown, onmouseup, 和 onmousemove 事件。对其他事件,
不管鼠标状态如何,都返回 0 (比如 onclick )。