typeEvent Properties
Event Object
Definition and Usage
The type event property returns the type of event that occurred, i.e., the name of the event represented by the current Event object.
It has the same name as the registered event handler, or it is the event handler attribute with the prefix "on" removed, such as "submit", "load", or "click".
Syntax
event.type
Example
Example
The following example can return the type of the triggered event:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script type="text/javascript">
function getEventType(event){
alert(event.type);
}
</script>
</head>
<body onmousedown="getEventType(event)">
<p>Click somewhere in the document. A message box will prompt you with the type of event that was triggered.</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script type="text/javascript">
function getEventType(event){
alert(event.type);
}
</script>
</head>
<body onmousedown="getEventType(event)">
<p>Click somewhere in the document. A message box will prompt you with the type of event that was triggered.</p>
</body>
</html>
Try it Yourself »
Event Object Other Extensions