XML DOM type event attribute

Definition and Usage

The type event attribute returns the type of the event that occurred, that is, the name of the event represented by the current Event object.

It has the same name as the registered event handler, or is the prefix "on" of the event handler attribute removed, such as "submit", "load", or "click".

Syntax

event.type

Example

The following example can return the type of the event triggered:

<html>
<head>
<script type="text/javascript">
function getEventType(event)
  { 
  alert(event.type);
  }
</script>
</head>
<body onmousedown="getEventType(event)">
<p>Click somewhere in the document.
An alert box will tell what event 
type you triggered.</p>
</body>
</html>

Try It Yourself (TIY)

type event
Return the type of event triggered (Internet Explorer browser does not support).