Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

event.type

概述

返回一个字符串, 表示该事件对象的事件类型.

传给 EventTarget.addEventListener()EventTarget.removeEventListener() 方法的 event 参数的值是忽略大小写的.

要了解所有的事件类型, 请查看 Mozilla 事件类型参考.

语法

event.type

示例

var string = event.type;
<!DOCTYPE html>
<html lang="en">
<head>

<title>type example</title>

<script>
var currEvent = null;

function getEvtType(evt) {
  currEvent = evt.type;
  document.getElementById("Etype").firstChild.nodeValue = currEvent;
}

</script>
</head>

<body
  onkeydown="getEvtType(event)"
  onkeyup="getEvtType(event)"
  onmousedown="getEvtType(event)"
  onmouseup="getEvtType(event)">

<p>Press any key or click the mouse to get the event type.</p>
<p>Event type: <span id="Etype">-</span></p>

</body>
</html>

规范

文档标签和贡献者

 此页面的贡献者: teoli, ziyunfei
 最后编辑者: teoli,