HTML DOM——Event对象
-
判断鼠标按键
function test(event) { alert(event.button); }
- 鼠标点击坐标
function test(event) { alert(event.clientX + "," + event.clientY);
//alert(event.screenX + "," + event.screenY); } - 判断键盘按键
function test(event) { alert(event.keyCode); }
- 判断是否按下了SHIFT
function test(event) { alert(event.shiftKey); }
- 判断点击的元素
function test(event) { alert(event.srcElement.tagName); //alert(event.target.tagName); }
- 判断触发的事件类型
function test(event) { alert(event.type); }