事件对象
onclick=“test(1,event)"; 事件产生的同时,会创建一个event事件对象,此对象中可以包含事件的一些信息。
event.button 鼠标标记位 0-左键 1-滚轮 2-右键
event.type 事件的类型
e.offsetX+"---"+e.offsetY 获得鼠标在当前标签中的坐标
e.clientX+"---"+e.clientY 获得鼠标在浏览器中的坐标
e.keyCode 获得按键的编码
e.altKey 按下alt键返回true
e.ctrlKey
e,shiftKey
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
function test(a,e){
console.log(e.keyCode);
console.log(e.ctrlKey);
console.log(e.altKey);
console.log(e.shiftKey);
}
</script>
</head>
<body>
<input type="button" value="测试" onmousedown="test(1,event)" />
<div onclick="test(1,event)" style="background-color: antiquewhite; width: 200px; height: 200px; margin-top: 20px;"></div>
</body>
</html>